Bash variables
Jump to navigation
Jump to search
Finding defined variables
Assuming you have done something like foo="bar" at your bash prompt it is not always clear how to echo ALL the defined variables back from your bash session. The following is a good way to get that information when needed. This can also be useful for debugging scripts that you are in the process of building out.
declare -p
If you only want the environment variables, and do not want to use env for some reason
declare -xp
An alternate command that will also give nice and parsable results
compgen -v | while read line; do echo $line=${!line};done