Go to the previous, next section.


A series of awk statements attached to a rule. If the rule's pattern matches an input record, the awk language executes the rule's action. Actions are always enclosed in curly braces. See section Overview of Actions.

Amazing awk Assembler
Henry Spencer at the University of Toronto wrote a retargetable assembler completely as awk scripts. It is thousands of lines long, including machine descriptions for several 8-bit microcomputers. It is a good example of a program that would have been better written in another language.

The American National Standards Institute. This organization produces many standards, among them the standard for the C programming language.

An awk expression that changes the value of some awk variable or data object. An object that you can assign to is called an lvalue. See section Assignment Expressions.

awk Language
The language in which awk programs are written.

awk Program
An awk program consists of a series of patterns and actions, collectively known as rules. For each input record given to the program, the program's rules are all processed in turn. awk programs may also contain function definitions.

awk Script
Another name for an awk program.

Built-in Function
The awk language provides built-in functions that perform various numerical, time stamp related, and string computations. Examples are sqrt (for the square root of a number) and substr (for a substring of a string). See section Built-in Functions.

Built-in Variable
ARGC, ARGIND, ARGV, CONVFMT, ENVIRON, ERRNO, FIELDWIDTHS, FILENAME, FNR, FS, IGNORECASE, NF, NR, OFMT, OFS, ORS, RLENGTH, RSTART, RS, and SUBSEP, are the variables that have special meaning to awk. Changing some of them affects awk's running environment. See section Built-in Variables.

See "Curly Braces."

The system programming language that most GNU software is written in. The awk programming language has C-like syntax, and this manual points out similarities between awk and C when appropriate.

A preprocessor for pic that reads descriptions of molecules and produces pic input for drawing them. It was written by Brian Kernighan, and is available from netlib@research.att.com.

Compound Statement
A series of awk statements, enclosed in curly braces. Compound statements may be nested. See section Control Statements in Actions.

Concatenating two strings means sticking them together, one after another, giving a new string. For example, the string `foo' concatenated with the string `bar' gives the string `foobar'. See section String Concatenation.

Conditional Expression
An expression using the `?:' ternary operator, such as expr1 ? expr2 : expr3. The expression expr1 is evaluated; if the result is true, the value of the whole expression is the value of expr2 otherwise the value is expr3. In either case, only one of expr2 and expr3 is evaluated. See section Conditional Expressions.

Constant Regular Expression
A constant regular expression is a regular expression written within slashes, such as `/foo/'. This regular expression is chosen when you write the awk program, and cannot be changed doing its execution. See section How to Use Regular Expressions.

Comparison Expression
A relation that is either true or false, such as (a < b). Comparison expressions are used in if, while, and for statements, and in patterns to select which input records to process. See section Comparison Expressions.

Curly Braces
The characters `{' and `}'. Curly braces are used in awk for delimiting actions, compound statements, and function bodies.

Data Objects
These are numbers and strings of characters. Numbers are converted into strings and vice versa, as needed. See section Conversion of Strings and Numbers.

Dynamic Regular Expression
A dynamic regular expression is a regular expression written as an ordinary expression. It could be a string constant, such as "foo", but it may also be an expression whose value may vary. See section How to Use Regular Expressions.

Escape Sequences
A special sequence of characters used for describing nonprinting characters, such as `\n' for newline, or `\033' for the ASCII ESC (escape) character. See section Constant Expressions.

When awk reads an input record, it splits the record into pieces separated by whitespace (or by a separator regexp which you can change by setting the built-in variable FS). Such pieces are called fields. If the pieces are of fixed length, you can use the built-in variable FIELDWIDTHS to describe their lengths. See section How Input is Split into Records.

Format strings are used to control the appearance of output in the printf statement. Also, data conversions from numbers to strings are controlled by the format string contained in the built-in variable CONVFMT. See section Format-Control Letters.

A specialized group of statements often used to encapsulate general or program-specific tasks. awk has a number of built-in functions, and also allows you to define your own. See section Built-in Functions. Also, see section User-defined Functions.

The GNU implementation of awk.

"GNU's not Unix". An on-going project of the Free Software Foundation to create a complete, freely distributable, POSIX-compliant computing environment.

Input Record
A single chunk of data read in by awk. Usually, an awk input record consists of one line of text. See section How Input is Split into Records.

In the awk language, a keyword is a word that has special meaning. Keywords are reserved and may not be used as variable names.

awk's keywords are: if, else, while, do...while, for, for...in, break, continue, delete, next, function, func, and exit.

An expression that can appear on the left side of an assignment operator. In most languages, lvalues can be variables or array elements. In awk, a field designator can also be used as an lvalue.

A numeric valued data object. The gawk implementation uses double precision floating point to represent numbers.

Patterns tell awk which input records are interesting to which rules.

A pattern is an arbitrary conditional expression against which input is tested. If the condition is satisfied, the pattern is said to match the input record. A typical pattern might compare the input record against a regular expression. See section Patterns.

The name for a series of standards being developed by the IEEE that specify a Portable Operating System interface. The "IX" denotes the Unix heritage of these standards. The main standard of interest for awk users is P1003.2, the Command Language and Utilities standard.

Range (of input lines)
A sequence of consecutive lines from the input file. A pattern can specify ranges of input lines for awk to process, or it can specify single lines. See section Patterns.

When a function calls itself, either directly or indirectly. If this isn't clear, refer to the entry for "recursion."

Redirection means performing input from other than the standard input stream, or output to other than the standard output stream.

You can redirect the output of the print and printf statements to a file or a system command, using the `>', `>>', and `|' operators. You can redirect input to the getline statement using the `<' and `|' operators. See section Redirecting Output of print and printf.

Regular Expression
See "regexp."

Short for regular expression. A regexp is a pattern that denotes a set of strings, possibly an infinite set. For example, the regexp `R.*xp' matches any string starting with the letter `R' and ending with the letters `xp'. In awk, regexps are used in patterns and in conditional expressions. Regexps may contain escape sequences. See section Regular Expressions as Patterns.

A segment of an awk program, that specifies how to process single input records. A rule consists of a pattern and an action. awk reads an input record; then, for each rule, if the input record satisfies the rule's pattern, awk executes the rule's action. Otherwise, the rule does nothing for that input record.

Side Effect
A side effect occurs when an expression has an effect aside from merely producing a value. Assignment expressions, increment expressions and function calls have side effects. See section Assignment Expressions.

Special File
A file name interpreted internally by gawk, instead of being handed directly to the underlying operating system. For example, `/dev/stdin'. See section Standard I/O Streams.

Stream Editor
A program that reads records from an input stream and processes them one or more at a time. This is in contrast with batch programs, which may expect to read their input files in entirety before starting to do anything, and with interactive programs, which require input from the user.

A datum consisting of a sequence of characters, such as `I am a string'. Constant strings are written with double-quotes in the awk language, and may contain escape sequences. See section Constant Expressions.

A sequence of blank or tab characters occurring inside an input record or a string.

Go to the previous, next section.