
770
|
Chapter 11: The gawk Programming Language
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
gawk, which provides a number of additional features. This utility can be invoked
either through the standard name awk or through gawk.
Items described here as “common extensions” are available in gawk and most
versions of awk offered on other operating systems (often called nawk for “new
awk”), but should not be used if strict portability of your programs is important
to you.
With gawk, you can:
• Think of a text file as made up of records and fields in a textual database.
• Perform arithmetic and string operations.
• Use programming constructs, such as loops and conditionals.
• Produce formatted reports.
• Define your own functions.
• Execute Unix commands from a script.
• Process the results of Unix commands.
• Process command-line arguments gracefully.
• Work easily with multiple input streams.
• Flush open output files and pipes.
• Sort arrays.
• Retrieve and format system time values.
• Do bit manipulation.
• Internationalize your gawk programs, allowing strings to be translated into a
local language at runtime.
• Perform two-way I/O to a coprocess.
• Open a two-way TCP/IP connection to a socket.
• Dynamically add built-in functions.
• Profile your gawk programs.
Command-Line Syntax
The syntax for invoking awk has two forms:
awk [options] 'script ...