If you want to print all environment variables, you can use printenv. Command printenv print all or just part of environment variables:
printenv
If you want to get names of variables, that was exported, you can use export command:
export
You can use also just env command. If you want to see all environment variables:
env
In fact, env run some program in modified environment. In next example, env will run only with variable called "DIRECTORY":
env -i DIRECTORY="/etc/mydir" bash
env
If you want to see functions, that you have declared, you can use "declare -f". Maybe you have not defined any function. To overcome this, in next example, we defined FUNKY_FUNCTION first:
FUNKY_FUNCTION ()
{
echo ":-)"
}
declare -f
Next command include shell variables to output:
( set -o posix ; set ) | less
This command shows not only shell variables, but environment variables too.
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek