Chapter Summary

 < Day Day Up > 

The gawk utility is a pattern-scanning and processing language that searches one or more files to see whether they contain records (usually lines) that match specified patterns. It processes lines by performing actions, such as writing the record to standard output or incrementing a counter, each time it finds a match.

A gawk program consists of one or more lines containing a pattern and/or action in the following format:

 pattern { action } 

The pattern selects lines from the input. The gawk utility performs the action on all lines that the pattern selects. If a program line does not contain a pattern, gawk selects all lines in the input. If a program line does not contain an action, gawk copies the selected lines to standard output.

A gawk program can use variables, functions, arithmetic operators, associative arrays, control statements, and C's printf statement. Advanced gawk programming takes advantage of getline statements to fine-tune input, coprocesses to enable gawk to exchange data with other programs, and network connections to exchange data with programs running on remote systems on a network.

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

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