21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix A: The Evolution of the awk Language 257Appendix A The Evolution of the awk LanguageThis book describes the GNU implementation of awk, which follows the POSIX specification.Many long-time awk users learned awk programming with the original awk implementationin Version 7 Unix. (This implementation was the basis for awk in Berkeley Unix, through4.3-Reno. Subsequent versions of Berkeley Unix, and systems derived from 4.4BSD-Lite,use various versions of gawk for their awk.) This chapter briefly describes the evolution ofthe awk language, with cross-references to other parts of the book where you can find moreinformation.A.1 Major Changes Between V7 and SVR3.1The awk language evolved considerably between the release of Version 7 Unix (1978) andthe new version that was first made generally available in System V Release 3.1 (1987).This section summarizes the changes, with cross-references to further details:• The requirement for ‘;’ to separate rules on a line (see Section 1.6 [awk StatementsVersus Lines], page 21).• User-defined functions and the return statement (see Section 8.2 [User-Defined Functions],page 153).• The delete statement (see Section 7.6 [The delete Statement], page 123).• The do-while statement (see Section 6.4.3 [The do-while Statement], page 104).• The built-in functions atan2, cos, sin, rand, and srand (see Section 8.1.2 [NumericFunctions], page 130).• The built-in functions gsub, sub, and match (see Section 8.1.3 [String-ManipulationFunctions], page 132).• The built-in functions close and system (see Section 8.1.4 [Input/Output Functions],page 143).• The ARGC, ARGV, FNR, RLENGTH, RSTART, and SUBSEP built-in variables (see Section 6.5[Built-in Variables], page 110).• Assignable $0.• The conditional expression using the ternary operator ‘?:’ (see Section 5.12 [ConditionalExpressions], page 92).• The expression ‘index-variable in array’ outside of ‘for’ statements (see Section 7.2[Referring to an Array Element], page 120).• The exponentiation operator ‘^’ (see Section 5.5 [Arithmetic Operators], page 81) andits assignment operator form ‘^=’ (see Section 5.7 [Assignment Expressions], page 83).• C-compatible operator precedence, which breaks some old awk programs (seeSection 5.14 [Operator Precedence (How Operators Nest)], page 94).• Regexps as the value of FS (see Section 3.5 [Specifying How Fields Are Separated],page 43) and as the third argument to the split function (see Section 8.1.3 [String-Manipulation Functions], page 132), rather than using only the first character of FS.• Dynamic regexps as operands of the ‘~’ and ‘!~’ operators (see Section 2.1 [How to UseRegular Expressions], page 24).

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

Saved successfully!

Ooh no, something went wrong!