Print all environment variables, including hidden ones
Print all environment variables, including hidden ones
1
|
This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the ‘env‘ command which according to the bash docs are more for internal use by BASH. The main trick is the way bash will list all environment variable names when performing expansion on ${!A*}. Then the eval builtin makes it work in a loop.
I created a function for this and use it instead of env. (by aliasing env).
This is the function that given any parameters lists the variables that start with it. So ‘aae B’ would list all env variables starting wit B. And ‘aae {A..Z} {a..z}’ would list all variables starting with any letter of the alphabet. And ‘aae TERM’ would list all variables starting with TERM.
1
|
And my printenv replacement is:
1
|
From: http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
* View this command to comment, vote or add to favourites * View all commands by AskApache
commandlinefu.com
by David Winterbottom (codeinthehole.com)
URL: http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones
Related articles
- Cool Linux command tricks (ghacks.net)
- Understanding Bash History (symkat.com)
- imabonehead: Boot process of Debian on the SheevaPlug (cyrius.com)
- Linux Commands (roezer.com)
Related Articles:
- 2010/09/24 bash script to run a command and take screenshot in every loop.
- 2010/09/01 Use the last command\’s output as input to a command without piping and bind to it to a key sequence in bash.
- 2010/08/13 tee to a file descriptor
- 2010/06/22 cdargs – bash cd command with bookmarks and browser.
- 2010/05/10 coproc help - a new feature in bash
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.