passing parameters using awk

Hi,
The below script is working fine

awk1.sh
=======
awk BEGIN {  FS="|"  }  FNR==NR { f1[$1]=$2; next }  $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} 

awk -f awk1.sh a.txt b.txt--Its working fine .



When passing parameters its not working .Any help it should be appereciated.

awk -f awk2.sh  xx a.txt b.txt 


awk2.sh
=======
param =$1
file1 =$2
file2 =$3
awk BEGIN {  FS="|"  }  FNR==NR { f1[$1]=$2; next }  $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} $file1 $file2

Thanks ,
Akil

What do you mean by not working? It's not reading the files correctly? It is giving you an error?

When passing ,i was getting the below error

param =$1
file1 =$2
file2 =$3
awk BEGIN { FS="|" } FNR==NR { f1[$1]=$2; next } $1 in f1 && $2 =="$param" && $1 == "DAILY_JOB" {print $3} $file1 $file2

awk -f awk2.sh xx a.txt b.txt

awk: Cannot find or open file XX
The source line number is 5.

Instead of using awk to process your sh just call your shell script.

Instead of

awk -f awk2.sh xx a.txt b.txt

Just run

awk2.sh xx a.txt b.txt

Hi
When try this I am getting the below error

awk2.sh xx a.txt b.txt

syntax error The source line is 1.
The error context is
>>> BEGIN <<<
awk: Quitting
The source line is 1.
d.sh[6]: Syntax error at line 7 : `}' is not expected.