O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Built-in Variables

All awk variables are included in gawk.

Version

Variable

Description

awk

ARGC

Number of arguments on the command line.

 

ARGV

An array containing the command-line arguments, indexed from 0 to ARGC - 1.

 

ENVIRON

An associative array of environment variables.

 

FILENAME

Current filename.

 

FNR

Like NR, but relative to the current file.

 

FS

Field separator (a space).

 

NF

Number of fields in current record.

 

NR

Number of the current record.

 

OFMT

Output format for numbers (“%.6g”).

 

OFS

Output field separator (a space).

 

ORS

Output record separator (a newline).

 

RLENGTH

Length of the string matched by match( ) function.

 

RS

Record separator (a newline).

 

RSTART

First position in the string matched by match( ) function.

 

SUBSEP

Separator character for array subscripts (“\034”).

 

$0

Entire input record.

 

$n

nth field in current record; fields are separated by FS.

gawk

ARGIND

Index in ARGV of current input file.

 

BINMODE

Controls binary I/O for input and output files. Use values of 1, 2, or 3 for input, output, or both kinds of files, respectively. Set it on the command line to affect standard input, standard output, and standard error.

 

ERRNO

A string indicating the error when a redirection fails for getline or if close( ) fails.

 

FIELDWIDTHS

A space-separated list of field widths to use for splitting up the record, instead of FS.

 

IGNORECASE

When true, all regular expression matches, string comparisons, and index( ) ignore case.

 

LINT

Dynamically controls production of “lint” warnings. With a value of “fatal”, lint warnings ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required