awk in shell script...

I have an awk script contained within a ksh script that I want to read the contents of a file with, say 3 records. Fields are a, b, and c, delimiter '|'.

I want to read the file and then I want to set different variables for $1, $2, $3 to be used as parameters to run a series of reports outside the scope of the awk script but within the same ksh script.

How do I do this? I am lost right now. Here's partially what I have..

# Run each of the reports in series (3 total) for each record:
awk '
BEGIN{FS="|";FILENAME="$loc/myfile"}
split(FILENAME,results,FS)

 a=results[1]
 b=results[2]
 c=results[3] 

etc.

Thanks very much. I have looked in Oreilley, FAQ, and on awk tutorial site but doesn't show me how to do s/t like this -- How to execute the rest of a command like sacego within/outside of? awk using parameters retrieved in the awk program.

Please advise.

Giannicello

I cannot understand your code, but I gather that you have a file with three data fields per line and the fields are delimited by | like this:
1|2|3
4|5|6
I think that you want to loop and set a=1, b=2, and c=3 on the first loop and a=4, b=5, and c=6 on the second loop. That is easy...

/usr/bin/ksh
exec < inputfile
IFS='|'
while read a b c ; do
    echo a = $a
    echo b = $b
    echo c = $c
done
exit 0

I don't see an easy way to inject awk into something like this.

Thank you sooo much. That was awesome. I never thought of that.

It worked beautifully! That took 1 minute to fix my script and tested it.

You're my hero.