The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-30-2007
jerome Sukumar jerome Sukumar is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 22
file Lookup using awk

Hi All,

I have two files file1 and file2(lookup file).I need to map more than one keyfields of file1 with file2.how can we achieve it using awk.

file1(max 2.2 million records)
--------------------------
680720|680721|077
680720|680721|978
680721|680722|090

file2(no idea about the record count)
---------------------------------------
680721|A|680720
680722|B|680721

Assumptions:
1)file 2 will not have any duplicate records.
2)no idea about the number of records.

Keyfields:1,2 for file1 and 3,1 for file2
Output
---------
680720|680721|077|A
680720|680721|978|A
680721|680722|090|B

Please help me how to go about.
I can try with arrays but as file2 record is not fixed, i cant take in array.please suggest me.

regards,
sukumar