GNU Info

Info Node: (gawk.info)Using Variables

(gawk.info)Using Variables


Next: Assignment Options Prev: Variables Up: Variables
Enter node , (file) or (file)node

Using Variables in a Program
----------------------------

   Variables let you give names to values and refer to them later.
Variables have already been used in many of the examples.  The name of
a variable must be a sequence of letters, digits, or underscores, and
it may not begin with a digit.  Case is significant in variable names;
`a' and `A' are distinct variables.

   A variable name is a valid expression by itself; it represents the
variable's current value.  Variables are given new values with
"assignment operators", "increment operators", and "decrement
operators".  Note: Assignment Expressions.

   A few variables have special built-in meanings, such as `FS' (the
field separator), and `NF' (the number of fields in the current input
record).  Note: Built-in Variables, for a list of the built-in
variables.  These built-in variables can be used and assigned just like
all other variables, but their values are also used or changed
automatically by `awk'.  All built-in variables' names are entirely
uppercase.

   Variables in `awk' can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a
program.  By default, variables are initialized to the empty string,
which is zero if converted to a number.  There is no need to
"initialize" each variable explicitly in `awk', which is what you would
do in C and in most other traditional languages.


automatically generated by info2www version 1.2.2.9