Files and pipes
You can provide input to an
awk
program by putting the input data into a file, say
awkdata,
and then executing
$ awk 'program' awkdata<<Return>>
If no filenames are given,
awk
reads its standard input;
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,
since this is the only thing it does.
We could, therefore, invoke the pipe
$ grep 'Asia' countries | awk '. . .'<<Return>>
grep
quickly finds the lines containing
Asia
and passes them on to the
awk
program for subsequent processing.
Next topic:
Input separators
Previous topic:
Input
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005