Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


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  
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..
# 2  
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:
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
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...... Shell Programming and Scripting
5
Shell Programming and Scripting
Print the 1st column and the value in 2nd or 3rd column if that is different from the values in 1st
Syeda Sumayya
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 ...... Linux
2
Linux
1st column,2nd column on first line 3rd,4th on second line ect...
batcho
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!... Shell Programming and Scripting
6
Shell Programming and Scripting
Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched
mustafa.abdulsa
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...... Shell Programming and Scripting
22
Shell Programming and Scripting
Strings from one file which exactly match to the 1st column of other file and then print lines.
AshwaniSharma09
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 ...... Shell Programming and Scripting
4
Shell Programming and Scripting

Featured Tech Videos