declare

The bash builtin that creates variables with attributes: -i integer, -r read-only, -a array, -A associative array, -n name reference, and -p to print.

In more detail

Inside a function, declare makes the variable local just as local does. declare -p name shows exactly how a variable is set, including its attributes, which helps when debugging arrays.

Examples

declare -A owner
declare -p files

Related terms

Taught in

References