bash keyword declare
declare [-aAfFgiIlnrtux] [-p] [name[=value] ...]
typeset [-aAfFgiIlnrtux] [-p] [name[=value] ...]
Declare variables and/or give them attributes. If
no names are given then display the values of
variables. The -p
option will display the
attributes and values of each name.
The following options can be used to restrict
output to variables with the specified attribute
or to give variables attributes:
- -a Each name is an indexed array variable (see Arrays above).
- -A Each name is an associative array variable (see Arrays above).
- -f Use function names only.
- -i The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION above) is performed when the variable is assigned a value.
- -l When the variable is assigned a value, all upper‐case characters are converted to lower‐case. The upper‐case attribute is disabled.
- -n Give each name the nameref attribute, making it a name reference to another variable. That other variable is defined by the value of name. All references, assignments, and attribute modifica‐ tions to name, except those using or changing the -n attribute itself, are performed on the variable referenced by name’s value. The nameref attribute cannot be applied to array variables.
- -r Make names readonly. These names cannot then be assigned values by subsequent assignment statements or unset.
- -t Give each name the trace attribute. Traced functions inherit the DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables.
- -u When the variable is assigned a value, all lower‐case characters are converted to upper‐case. The lower‐case attribute is disabled.
- -x Mark names for export to subsequent commands via the environment.