|
RTR's Win95Pak: The GAWK Manual - The Evolution of the awk Language
Go to the previous, next chapter.
This manual describes the GNU implementation of awk, which is patterned
after the POSIX specification. Many awk users are only familiar
with the original awk implementation in Version 7 Unix, which is also
the basis for the version in Berkeley Unix (through 4.3--Reno). This chapter
briefly describes the evolution of the awk language.
- V7/S5R3.1: The major changes between V7 and
System V Release 3.1.
- S5R4: Minor changes between System V
Releases 3.1 and 4.
- POSIX: New features from the posix standard.
- POSIX/GNU: The extensions in
gawk
not in posix awk.
The awk language evolved considerably between the release of
Version 7 Unix (1978) and the new version first made widely 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
(note `awk' Statements versus Lines}).
- User-defined functions, and the
return statement
(see section User-defined Functions).
-
The
delete statement.
The do-while statement
(note: The do-while Statement).
-
The built-in functions
atan2, cos, sin, rand and
srand (see section Numeric Built-in Functions).
-
The built-in functions
gsub, sub, and match
(see section Built-in Functions for String Manipulation).
-
The built-in functions
close, which closes an open file, and
system, which allows the user to execute operating system
commands (see section Built-in Functions for Input/Output).
-
The
ARGC, ARGV, FNR, RLENGTH, RSTART,
and SUBSEP built-in variables (see section Built-in Variables).
-
The conditional expression using the operators ? and :
(see section Conditional Expressions).
-
The exponentiation operator ^
(see section Arithmetic Operators) and its assignment operator
form ^= (see section Assignment Expressions).
-
C-compatible operator precedence, which breaks some old
awk
programs.
-
Regexps as the value of
FS
(see section Specifying how Fields are Separated), and as the
third argument to the split function
(see section Built-in Functions for String Manipulation).
-
Dynamic regexps as operands of the ~ and !~ operators
(see section How to Use Regular Expressions).
-
Escape sequences (see section Constant Expressions) in regexps.
-
The escape sequences \b, \f, and \r
(see section Constant Expressions).
-
Redirection of input for the
getline function
(note: Explicit Input with getline.
- .Multiple
BEGIN and END rules
(note: BEGIN and END Special Patterns.
- Simulated multi-dimensional arrays
(see section Multi-dimensional Arrays).
The System V Release 4 version of Unix awk added these features
(some of which originated in gawk):
The POSIX Command Language and Utilities standard for awk
introduced the following changes into the language:
-
The use of -W for implementation-specific options.
-
The use of
CONVFMT for controlling the conversion of numbers
to strings (see section Conversion of Strings and Numbers).
-
The concept of a numeric string, and tighter comparison rules to go
with it (see section Comparison Expressions).
-
More complete documentation of many of the previously undocumented
features of the language.
The GNU implementation, gawk, adds these features:
-
The
AWKPATH environment variable for specifying a path search for
the -f command line option
- The various
gawk specific features available via the -W
command line option.
The ARGIND variable, that tracks the movement of FILENAME
through ARGV. (see section Built-in Variables).
-
The
ERRNO variable, that contains the system error message when
getline returns -1, or when close fails.
(see section Built-in Variables).
-
The
IGNORECASE variable and its effects
(see section Case-sensitivity in Matching).
-
The
FIELDWIDTHS variable and its effects
(see section Reading Fixed-width Data).
-
The
next file statement for skipping to the next data file
(note:The next file Statement).
- The
systime and strftime built-in functions for obtaining
and printing time stamps
(see section Functions for Dealing with Time Stamps).
-
The /dev/stdin, /dev/stdout, /dev/stderr, and
/dev/fd/n file name interpretation
(see section Standard I/O Streams).
-
The -W compat option to turn off these extensions
.
-
The -W posix option for full POSIX compliance
.
|