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

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

To see all exported variables and functions in Bash, you can use the export builtin command without any arguments.

The export builtin command displays the list of variables and functions that have been marked for export, and can be used to export variables and functions to the environment of subsequent commands.

To see the list of exported variables and functions, you can use the export command without any arguments, like this:

export
Sourc‮ual.www:e‬tturi.com

This will display the list of exported variables and functions, along with their values.

For example, if you have exported the variables FOO and BAR, and the function myfunc, the output of the export command will be:

declare -x BAR="bar"
declare -x FOO="foo"
declare -fx myfunc

You can use the declare builtin command to list all variables and functions, whether they are exported or not.

To list all variables, you can use the declare -p command, like this:

declare -p

To list all functions, you can use the declare -f command, like this:

declare -f

You can use the -x option with the declare command to list only exported variables, and the -f option to list only exported functions.

For example, to list only exported variables, you can use the declare -xp command, like this:

declare -xp

To list only exported functions, you can use the declare -xf command, like this:

declare -xf

Keep in mind that exported variables and functions are available to the environment of subsequent commands, and can be accessed by other processes or scripts.

Created Time:2017-10-29 22:08:58  Author:lautturi