gawk: Expressions Summary

1 
1 6.7 Summary
1 ===========
1 
1    * Expressions are the basic elements of computation in programs.
1      They are built from constants, variables, function calls, and
1      combinations of the various kinds of values with operators.
1 
1    * 'awk' supplies three kinds of constants: numeric, string, and
1      regexp.  'gawk' lets you specify numeric constants in octal and
1      hexadecimal (bases 8 and 16) as well as decimal (base 10).  In
1      certain contexts, a standalone regexp constant such as '/foo/' has
1      the same meaning as '$0 ~ /foo/'.
1 
1    * Variables hold values between uses in computations.  A number of
1      built-in variables provide information to your 'awk' program, and a
1      number of others let you control how 'awk' behaves.
1 
1    * Numbers are automatically converted to strings, and strings to
1      numbers, as needed by 'awk'.  Numeric values are converted as if
1      they were formatted with 'sprintf()' using the format in 'CONVFMT'.
1      Locales can influence the conversions.
1 
1    * 'awk' provides the usual arithmetic operators (addition,
1      subtraction, multiplication, division, modulus), and unary plus and
1      minus.  It also provides comparison operators, Boolean operators,
1      an array membership testing operator, and regexp matching
1      operators.  String concatenation is accomplished by placing two
1      expressions next to each other; there is no explicit operator.  The
1      three-operand '?:' operator provides an "if-else" test within
1      expressions.
1 
1    * Assignment operators provide convenient shorthands for common
1      arithmetic operations.
1 
1    * In 'awk', a value is considered to be true if it is nonzero _or_
1      non-null.  Otherwise, the value is false.
1 
1    * A variable's type is set upon each assignment and may change over
1      its lifetime.  The type determines how it behaves in comparisons
1      (string or numeric).
1 
1    * Function calls return a value that may be used as part of a larger
1      expression.  Expressions used to pass parameter values are fully
1      evaluated before the function is called.  'awk' provides built-in
1      and user-defined functions; this is described in ⇒Functions.
1 
1    * Operator precedence specifies the order in which operations are
1      performed, unless explicitly overridden by parentheses.  'awk''s
1      operator precedence is compatible with that of C.
1 
1    * Locales can affect the format of data as output by an 'awk'
1      program, and occasionally the format for data read as input.
1