Linux / Unix: Bash Shell See All Exported Variables and Functions

To see all exported variables and functions in the bash shell, you can use the following command:

declare -p | grep -E '^declare -[a-zA-Z]*x'

This will show all exported variables and functions in the current shell session, including environment variables, shell functions, and aliases. The declare command is used to show the values of shell variables, and the grep command filters the output to show only exported variables and functions.

For example:

$ export foo=bar
$ declare -p | grep -E '^declare -[a-zA-Z]*x'
declare -x foo="bar"

This shows that the variable foo has been exported with the value bar.

Leave a Comment