awk '{ if (veg == $1)
printf "%s
%.2f\n", $1, $2*$3 }' veg=$1 vegetables
A. Everything within the context of quotes '....' is under the context of awk. Here $1, $2, ...$i refer to the fields in the record.
B. The veg=$1 assignment is a command to the shell and veg is set to argument 1 in the shell. Do a man on awk and check the functionality of the -v argument to clarify.
C. To access the arguments within the context of awk, you will have
to manipulate the special variables ARGC and ARGV(just like in C).
ARGC
The number of
elements in the ARGV array.
ARGV
An array
of command line arguments, excluding options and the
program_file arguments, numbered from zero to ARGC-1.