|
AWK script
I have written an awk script. If i run it from command prompt with awk -f then it working fine. but when run the same statements in a script and named file as a1.awk and tried to run it awk -f a1.awk temp.txt > temp2.txt I doesn't work.
The script is like this
awk -F'|' '
BEGIN{
}
{ if($4=="1"){
print "*********" a[$3]
if( a[$3] < $6 ){
a[$3]=$7;
b[$3]=$2;
}
else if ( a[$3] == $7 ){
if( $9 == 1 ){
b[$3]=$2;
}
}
}
next;
}
END {
for ( x in b ) {
print x "|" b[x]
}
}
' temp1.txt> /var/tmp/temp2.txt
The above things works fine but when I put same thing in a script like
a1.awk
and run the script awk -f a1.awk temp1.txt > temp2.txt
No output is written to output file.
Please help me.
|