[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A.5 Extensions in gawk
Not in POSIX awk
The GNU implementation, gawk
, adds a large number of features.
They can all be disabled with either the ‘--traditional’ or
‘--posix’ options
(see section Command-Line Options).
A number of features have come and gone over the years. This section
summarizes the additional features over POSIX awk
that are
in the current version of gawk
.
-
Additional built-in variables:
- -
The
ARGIND
BINMODE
,ERRNO
,FIELDWIDTHS
,FPAT
,IGNORECASE
,LINT
,PROCINFO
,RT
, andTEXTDOMAIN
variables (see section Built-in Variables).
- -
The
-
Special files in I/O redirections:
- -
The ‘/dev/stdin’, ‘/dev/stdout’, ‘/dev/stderr’ and
‘/dev/fd/N’ special file names
(see section Special File Names in
gawk
). - -
The ‘/inet’, ‘/inet4’, and ‘/inet6’ special files for
TCP/IP networking using ‘|&’ to specify which version of the
IP protocol to use.
(see section Using
gawk
for Network Programming).
- -
The ‘/dev/stdin’, ‘/dev/stdout’, ‘/dev/stderr’ and
‘/dev/fd/N’ special file names
(see section Special File Names in
-
Changes and/or additions to the language:
- - The ‘\x’ escape sequence (see section Escape Sequences).
- - Full support for both POSIX and GNU regexps (see section Regular Expressions).
- -
The ability for
FS
and for the third argument tosplit()
to be null strings (see section Making Each Character a Separate Field). - -
The ability for
RS
to be a regexp (see section How Input Is Split into Records). - -
The ability to use octal and hexadecimal constants in
awk
program source code (see section Octal and Hexadecimal Numbers). - - The ‘|&’ operator for two-way I/O to a coprocess (see section Two-Way Communications with Another Process).
- - Indirect function calls (see section Indirect Function Calls).
- - Directories on the command line produce a warning and are skipped (see section Directories On The Command Line).
-
New keywords:
- -
The
BEGINFILE
andENDFILE
special patterns. (see section TheBEGINFILE
andENDFILE
Special Patterns). - -
The ability to delete all of an array at once with ‘delete array’
(see section The
delete
Statement). - -
The
nextfile
statement (see section Usinggawk
’snextfile
Statement). - -
The
switch
statement (see section Theswitch
Statement).
- -
The
-
Changes to standard
awk
functions:- -
The optional second argument to
close()
that allows closing one end of a two-way pipe to a coprocess (see section Two-Way Communications with Another Process). - -
POSIX compliance for
gsub()
andsub()
. - -
The
length()
function accepts an array argument and returns the number of elements in the array (see section String-Manipulation Functions). - -
The optional third argument to the
match()
function for capturing text-matching subexpressions within a regexp (see section String-Manipulation Functions). - -
Positional specifiers in
printf
formats for making translations easier (see section Rearrangingprintf
Arguments). - -
The
split()
function’s additional optional fourth argument which is an array to hold the text of the field separators. (see section String-Manipulation Functions).
- -
The optional second argument to
-
Additional functions only in
gawk
:- -
The
and()
,compl()
,lshift()
,or()
,rshift()
, andxor()
functions for bit manipulation (see section Bit-Manipulation Functions). - -
The
asort()
andasorti()
functions for sorting arrays (see section Controlling Array Traversal and Array Sorting). - -
The
bindtextdomain()
,dcgettext()
anddcngettext()
functions for internationalization (see section Internationalizingawk
Programs). - -
The
extension()
built-in function and the ability to add new functions dynamically (see section Adding New Built-in Functions togawk
). - -
The
fflush()
function from Brian Kernighan’s version ofawk
(see section Input/Output Functions). - -
The
gensub()
,patsplit()
, andstrtonum()
functions for more powerful text manipulation (see section String-Manipulation Functions). - -
The
mktime()
,systime()
, andstrftime()
functions for working with timestamps (see section Time Functions).
- -
The
-
Changes and/or additions in the command-line options:
- -
The
AWKPATH
environment variable for specifying a path search for the ‘-f’ command-line option (see section Command-Line Options). - - The ability to use GNU-style long-named options that start with ‘--’ and the ‘--characters-as-bytes’, ‘--compat’, ‘--dump-variables’, ‘--exec’, ‘--gen-pot’, ‘--lint’, ‘--lint-old’, ‘--non-decimal-data’, ‘--posix’, ‘--profile’, ‘--re-interval’, ‘--sandbox’, ‘--source’, ‘--traditional’, and ‘--use-lc-numeric’ options (see section Command-Line Options).
- -
The
-
Support for the following obsolete systems was removed from the code
and the documentation for
gawk
version 4.0:- - Amiga
- - Atari
- - BeOS
- - Cray
- - MIPS RiscOS
- - MS-DOS with the Microsoft Compiler
- - MS-Windows with the Microsoft Compiler
- - NeXT
- - SunOS 3.x, Sun 386 (Road Runner)
- - Tandem (non-POSIX)
- - Prestandard VAX C compiler for VAX/VMS
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |