|
|
You can provide input to an awk program by putting the
input data into a file, say awkdata, and then executing it
like this:
awk 'program' awkdata
awk reads its standard input if no filenames are given; thus, a second common arrangement is to have another program pipe its output into awk. For example, grep(C) selects input lines containing a specified regular expression, but it can do so faster than awk, because this is the only thing it does.
grep 'Asia' countries | awk '{ print $1 }'In this shell script, grep quickly finds the lines containing Asia and passes them on to the awk program for subsequent processing, where the first field is printed:
CIS China India