Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 5 Days Ago
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; 5 Days Ago at 10:05 AM..
# 2  
Old 5 Days Ago
Now, this problem has been solved umpteen times in these fora. Try searching relevant threads and adapting the given solutions. You may start with the links at this page's lower left under "More UNIX and Linux Forum Topics You Might Find Helpful".
This User Gave Thanks to RudiC For This Post:
tententen (2 Days Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Input file needs to match a column and print the entire line lewk Shell Programming and Scripting 5 06-16-2016 05:11 PM
Print the 1st column and the value in 2nd or 3rd column if that is different from the values in 1st Syeda Sumayya Linux 2 10-29-2015 04:44 AM
Remove entire line from a file if 1st column matches a pattern anshu ranjan Shell Programming and Scripting 3 06-11-2015 03:27 AM
How to read file line by line and compare subset of 1st line with 2nd? pat_pramod Shell Programming and Scripting 3 11-25-2014 02:41 AM
Match value in column and append file with new values redse171 Shell Programming and Scripting 8 09-10-2014 08:46 PM
awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column jacobs.smith Shell Programming and Scripting 3 11-14-2013 03:33 PM
Calculate 2nd Column Based on 1st Column attila Shell Programming and Scripting 3 11-22-2012 04:56 AM
Grep/Awk on 1st 2 Letters in 2nd Column of File TheNovice Shell Programming and Scripting 4 11-06-2012 02:41 PM
1st column,2nd column on first line 3rd,4th on second line ect... batcho Shell Programming and Scripting 6 04-06-2012 09:20 AM
comparing column of two different files and print the column from in order of 2nd file CAch Shell Programming and Scripting 14 08-24-2011 01:45 PM
Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched mustafa.abdulsa Shell Programming and Scripting 22 06-08-2011 05:31 AM
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 rydz00 Shell Programming and Scripting 7 11-09-2010 10:28 AM
Strings from one file which exactly match to the 1st column of other file and then print lines. AshwaniSharma09 Shell Programming and Scripting 4 08-19-2010 08:16 PM
Awk+Grep Input file needs to match a column and print the entire line poliver Shell Programming and Scripting 3 03-16-2009 09:09 AM
two files.say a and b.both have long columns.i wanna match the column fron 1st file w TRUPTI UNIX for Dummies Questions & Answers 4 10-17-2008 01:17 PM