Expressions are the basic building blocks of
awk patterns and actions. An expression evaluates
to a value that you can print, test, or pass to a function. Additionally, an
expression can assign a new value to a variable or a field by using an
An expression can serve as a pattern or action statement on its own.
Most other kinds of statements contain one or more expressions that specify
the data on which to operate. As in other languages, expressions in
awk can include variables, array references,
constants, and function calls, as well as combinations of these with various
Expressions are built up from values and the operations performed upon them. This section describes the elementary objects that provide the values used in expressions.
The simplest type of expression is the constant, which always has the same value. There are three types of constants: numeric, string, and regular expression.
Each is used in the appropriate context when you need a data value that isn’t going to change. Numeric constants can have different forms, but are internally stored in an identical manner.
A numeric constant stands for a number. This number can be an integer, a decimal fraction, or a number in scientific (exponential) notation. Here are some examples of numeric constants that all have the same value:
105 1.05e+2 1050e-1
A string constant consists of a sequence ...