Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd Post 303032264 by tententen on Thursday 14th of March 2019 09:51:53 AM
Old 03-14-2019
Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi


I have 2 file with more than 10 columns for both



1st file

Code:
apple,0,0,0......
orange,1,2,3.....
mango,2,4,5.....

2nd file
Code:
apple,2,3,4,5,6,7...
orange,2,3,4,5,6,8...
watermerlon,2,3,4,5,6,abc...
mango,5,6,7,4,6,def....

I want to match the first column of both file and if it matches, print the whole line from 1st file and append 7th column from 2nd file to it for everyline so it becomes like this


Code:
apple,0,0,0......7
orange,1,2,3.....8
mango,2,4,5.....def


Any help would be much appreciated
Moderator's Comments:
Mod Comment code tags please

Last edited by jim mcnamara; 03-14-2019 at 11:05 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

two files.say a and b.both have long columns.i wanna match the column fron 1st file w

ex: a file has : 122323 123456456 125656879 678989965t635 234323432 b has : this is finance no. this is phone no this is extn ajkdgag idjsidj i want the o/p as: 122323 his is finance no. 123456456 this is phone no 123456456 ... (4 Replies)
Discussion started by: TRUPTI
4 Replies

2. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

3. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

4. Shell Programming and Scripting

Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched

Hi Experts, I am very new to scripting and have a prb since few days and it is urgent to solve so much appreciated if u help me. i have 2 files file1.txt 9647810043118 9647810043126 9647810043155 9647810043161 9647810043166 9647810043185 9647810043200 9647810043203 9647810043250... (22 Replies)
Discussion started by: mustafa.abdulsa
22 Replies

5. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

6. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

7. Shell Programming and Scripting

Grep/Awk on 1st 2 Letters in 2nd Column of File

Hi everyone. I need to change a script (ksh) so that it will grep on the 1st 2 letters in the second column of a 5 column file such as this one: 192.168.1.1 CAXY0_123 10ABFL000001 # Comment 192.168.1.2 CAYZ0_123 10ABTX000002 # Comment 192.168.2.1 FLXY0_123 11ABCA000001 ... (4 Replies)
Discussion started by: TheNovice
4 Replies

8. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

9. Linux

Print the 1st column and the value in 2nd or 3rd column if that is different from the values in 1st

I have file that looks like this, DIP-17571N|refseq:NP_651151 DIP-17460N|refseq:NP_511165|uniprotkb:P45890 DIP-17571N|refseq:NP_651151 DIP-19241N|refseq:NP_524261 DIP-19241N|refseq:NP_524261 DIP-17151N|refseq:NP_524316|uniprotkb:O16797 DIP-19588N|refseq:NP_731165 ... (2 Replies)
Discussion started by: Syeda Sumayya
2 Replies

10. Shell Programming and Scripting

Input file needs to match a column and print the entire line

I have a file with class c IP addresses that I need to match to a column and print the matching lines of another file. I started playing with grep -if file01.out file02.out but I am stuck as to how to match it to a column and print the matching lines; cat file01.out 10.150.140... (5 Replies)
Discussion started by: lewk
5 Replies
NGRAPH(1)						      General Commands Manual							 NGRAPH(1)

NAME
Ngraph - creating scientific 2-dimensional graphs SYNOPSIS
ngraph [options] [data file(s) or ngp file] DESCRIPTION
Ngraph is the program to create scientific 2-dimensional graphs for researchers and engineers. Graphs can be exported to PostScript, SVG, PNG or PDF format. OPTIONS
Command line options are: -L file load ngp file -x column data column for the x axis -y column data column for the y axis -X use X axis as the x axis -Y use Y axis as the y axis -U use U axis as the x axis -R use R axis as the y axis -d {mark | line | polygon | curve | diagonal | arrow | rectangle | rectangle_fill | rectangle_solid_fill | errorbar_x | errorbar_y | stair- case_x | staircase_y | bar_x | bar_y | bar_fill_x | bar_fill_y | bar_solid_fill_x | bar_solid_fill_y | fit} specify plot type -m type specify mark type (0-89) -o size specify mark size -l style specify line style -w width specify line width -CR n specify red component of the 1st plot color (0-255) -CG n specify green component of the 1st plot color (0-255) -CB n specify blue component of the 1st plot color (0-255) -cr n specify red component of the 2nd plot color (0-255) -cg n specify green component of the 2nd plot color (0-255) -cb n specify blue component of the 2nd plot color (0-255) -s line specify number of the head skip -r step specify number of the read step -f line specify number of the final line -vx n neighbor average of the x data -vy n neighbor average of the y data -mx formula specify math transformation for the x data -my formula specify math transformation for the y data -ex {linear | log | inverse | MJD} specify scale type of the x axis -ey {linear | log | inverse | MJD} specify scale type of the y axis -minx value specify minimum value of x axis -maxx value specify maximum value of x axis -incx value specify increment value of x axis -miny value specify minimum value of y axis -maxy value specify maximum value of y axis -incy value specify increment value of y axis -g load settings from data file -png file convert ngp file to PNG format -pdf file convert ngp file to PDF format -ps file convert ngp file to PostScript format -eps file convert ngp file to Encapsulated PostScript format -svg file convert ngp file to SVG format -gra file convert ngp file to GRA format -dialog show print dialog (with -p option) -p file print ngp file -n output ngp-file to stdout -h, --help show help message -v, --version show version of Ngraph -V, --VERSION show detail information about Ngraph FILES
${HOME}/.Ngraph/Ngraph.nsc start up script ${HOME}/.Ngraph/Ngraph.ini configuration file ${HOME}/.Ngraph/Ngraph.ngp default graph AUTHORS
Satoshi ISHIZAKA Hiroyuki Ito <ZXB01226@nifty.com> SEE ALSO
ngp2(1) COPYRIGHT
Copyright (C) 2003 Satoshi ISHIZAKA Copyright (C) 2008-2011 Hiroyuki Ito 4th Berkeley Distribution Local NGRAPH(1)
All times are GMT -4. The time now is 09:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy