The UNIX and Linux Forums  

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 -->
  #3 (permalink)  
Old 05-27-2009
pisang pisang is offline
Registered User
  
 

Join Date: May 2009
Posts: 3
Quote:
Originally Posted by Franklin52 View Post
Can you show us what you have tried with awk?

Regards
I try this script, but it says "awk: fatal: can't open source file `BEGIN {"

script:
#!/bin/sh
DATA1=file1.txt
DATA2=file2.txt

awk -f 'BEGIN {
while ((getline < "'$DATA2'") > 0)
f2array[$2] = $1
OFS=","}

{if (f2array[$1])
print f2array[$1],$2,$3,$4,$5
}' $DATA1

Thanks for your time to read my thread Franklin