builtin

Bash declare -p — inspect variables

Displays the declaration and attributes of each named variable. Other declare options set attributes; inside functions additional scope rules apply. Output may contain values, so inspect only synthetic variables.

Formal Syntax & Structure

bash syntaxbash
declare -p name ...

Parameters & Attributes

NameTypeDescription
namestringVariable name.

Return Value

exit status

Zero on success, nonzero if a requested name is not found or another error occurs.

Working Example

Example Snippetbash
mode=demodeclare -p mode
Bash Reference