DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using awk

Files and pipes

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

Next topic: Input separators
Previous topic: Input

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003