Go forward to Statements.
Go backward to Actions.
Go up to Top.
Expressions as Action Statements
Expressions are the basic building block of `awk' actions. An
expression evaluates to a value, which you can print, test, store in a
variable or pass to a function. But beyond that, an expression can
assign a new value to a variable or a field, with an assignment
An expression can serve as a statement on its own. Most other kinds
of statements contain one or more expressions which specify data to be
operated on. As in other languages, expressions in `awk' include
variables, array references, constants, and function calls, as well as
combinations of these with various operators.
- String, numeric, and regexp constants.
- Variables give names to values for later use.
- Arithmetic Ops
- Arithmetic operations (`+', `-', etc.)
- Concatenating strings.
- Comparison Ops
- Comparison of numbers and strings
with `<', etc.
- Boolean Ops
- Combining comparison expressions
using boolean operators
`||' ("or"), `&&' ("and") and `!' ("not").
- Assignment Ops
- Changing the value of a variable or a field.
- Increment Ops
- Incrementing the numeric value of a variable.
- The conversion of strings to numbers
and vice versa.
- The whole truth about numbers and strings.
- Conditional Exp
- Conditional expressions select
between two subexpressions under control
of a third subexpression.
- Function Calls
- A function call is an expression.
- How various operators nest.