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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to merge two file based on multiple Keys (Without using JOIN)

Status
Not open for further replies.

manish607

Technical User
Jun 24, 2005
2
US
I have two file. I want to have them merged based of 2 keys. There can be multiple records having the same key. if the second file doesn't have a record for the Key, the firse file record will be present in the output will blank for second file.

How can we do it in Awk without using unix JOIN.

Main file
20,2,A
10,2,B
20,3,C
10,2,D
20,3,E
10,3,F

Reference file
10,1,A1
10,2,A2
10,3,A3
20,2,B1

Output file
B1,20,2,A
A2,10,2,B
,20,3,C
A2,10,2,D
,20,3,E
A3,10,3,F
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top