6.1. What s awk? What s nawk? What s gawk?

 <  Day Day Up  >  

6.1. What's awk ? What's nawk ? What's gawk ?

Awk is a UNIX programming language used for manipulating data and generating reports . Nawk is a newer version of awk , and gawk is the GNU version used on Linux.

The data may come from standard input, one or more files, or as output from a process. Awk can be used at the command line for simple operations, or it can be written into programs for larger applications. Because awk can manipulate data, it is an indispensable tool used in shell scripts and for managing small databases.

Awk scans a file (or input) line by line, from the first to the last line, searching for lines that match a specified pattern and performing selected actions ( enclosed in curly braces) on those lines. If there is a pattern with no specific action, all lines that match the pattern are displayed; if there is an action with no pattern, all input lines specified by the action are executed upon.

6.1.1 What Does awk Stand For?

Awk stands for the first initials in the last names of each of the authors of the language, Alfred Aho, Brian Kernighan, and Peter Weinberger. They could have called it wak or kaw , but for whatever reason, awk won out.

6.1.2 Which awk ?

There are a number of versions of awk : old awk , new awk , GNU awk ( gawk ), POSIX awk , and others. Awk was originally written in 1977, and in 1985, the original implementation was improved so that awk could handle larger programs. Additional features included user -defined functions, dynamic regular expressions, processing multiple input files, and more. On most systems, the command is awk if using the old version, nawk if using the new version, and gawk if using the GNU version. [1]

[1] On SCO UNIX, the new version is spelled awk , and on Linux, the GNU version is spelled gawk . This text pertains primarily to the new awk , nawk . The GNU implementation, gawk , is fully upward-compatible with nawk .

 <  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