Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract columns

Status
Not open for further replies.

pearlofperls

Technical User
Apr 5, 2007
24
US
I have :
5 columns in file 1
11 columns in file 2
file 1 has more lines than file 2
cols 1, 2, 4, match info between the two files
based on the critieria of matching cols i want to extract cols 3,5 from file 1 and add them with file 2

I think this code is close to what im looking to do

awk 'FNR==NR{a[$1,$2,$3]=$4" "$5;next}
{ print $1,$2,$3,a[$1,$2,$3]}' file2 file1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top