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




Thread: Doubt in awk
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-10-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Arrow Doubt in awk

Hi All,

I have two files as given below:

fileA
1234|aaaaa|vvvv
2222|bbbbbb|cbxxbjh
3333|cccc|jhjhj

fileB
3434|bbbcc|cbxxbjh
1234|cat|bullet
3333|cccc|jhjhj

I need a script that reads the first column from fileA (i.e 1234) and searches in fileB in the first parameter(i.e first column), if match found ( for example 1234 - line1 in fileA and 1234 - line 2 in fileB), then append the rest of the row in file and write to a new file

Example
Get first parameter in first row in fileA = 1234
search for the line with first parameter as 1234 in fileB.We get line 2.
write 1234|aaaaa|vvvv|cat|bullet to fileC.

Thanks in advance
JS