awk-pattern scanning and processing language

 <  Day Day Up  >  

awk ”pattern scanning and processing language

 awk [ fprogramfile ] [ Fc ] [ prog ] [ parameters ] [ filename...] 

awk scans each input filename for lines that match any of a set of patterns specified in prog .

Example A.4.
 1   awk '{print , }' file 2   awk '/John/{print , }' file 3   awk -F: '{print }' /etc/passwd 4   date  awk '{print }' 

EXPLANATION

  1. Prints the first two fields of file where fields are separated by whitespace.

  2. Prints fields 3 and 4 if the pattern John is found.

  3. Using a colon as the field separator, prints the third field of the /etc/passwd file .

  4. Sends the output of the date command to awk and prints the sixth field.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net