21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

258 <strong>G<strong>AWK</strong></strong>: <strong>Effective</strong> <strong>AWK</strong> <strong>Programming</strong>• The escape sequences ‘\b’, ‘\f’, and ‘\r’ (see Section 2.2 [Escape Sequences], page 25).(Some vendors have updated their old versions of awk to recognize ‘\b’, ‘\f’, and ‘\r’,but this is not something you can rely on.)• Redirection of input for the getline function (see Section 3.8 [Explicit Input withgetline], page 52).• Multiple BEGIN and END rules (see Section 6.1.4 [The BEGIN and END Special Patterns],page 99).• Multidimensional arrays (see Section 7.9 [Multidimensional Arrays], page 125).A.2 Changes Between SVR3.1 and SVR4The System V Release 4 (1989) version of Unix awk added these features (some of whichoriginated in gawk):• The ENVIRON variable (see Section 6.5 [Built-in Variables], page 110).• Multiple ‘-f’ options on the command line (see Section 11.2 [Command-Line Options],page 177).• The ‘-v’ option for assigning variables before program execution begins (see Section 11.2[Command-Line Options], page 177).• The ‘--’ option for terminating command-line options.• The ‘\a’, ‘\v’, and ‘\x’ escape sequences (see Section 2.2 [Escape Sequences], page 25).• A defined return value for the srand built-in function (see Section 8.1.2 [NumericFunctions], page 130).• The toupper and tolower built-in string functions for case translation (seeSection 8.1.3 [String-Manipulation Functions], page 132).• A cleaner specification for the ‘%c’ format-control letter in the printf function (seeSection 4.5.2 [Format-Control Letters], page 61).• The ability to dynamically pass the field width and precision ("%*.*d") in the argumentlist of the printf function (see Section 4.5.2 [Format-Control Letters], page 61).• The use of regexp constants, such as /foo/, as expressions, where they are equivalentto using the matching operator, as in ‘$0 ~ /foo/’ (see Section 5.2 [Using RegularExpression Constants], page 76).• Processing of escape sequences inside command-line variable assignments (seeSection 5.3.2 [Assigning Variables on the Command Line], page 78).A.3 Changes Between SVR4 and POSIX awkThe POSIX Command Language and Utilities standard for awk (1992) introduced the followingchanges into the language:• The use of ‘-W’ for implementation-specific options (see Section 11.2 [Command-LineOptions], page 177).• The use of CONVFMT for controlling the conversion of numbers to strings (see Section 5.4[Conversion of Strings and Numbers], page 79).• The concept of a numeric string and tighter comparison rules to go with it (seeSection 5.10 [Variable Typing and Comparison Expressions], page 87).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!