env and printenv
noun
say it: “EN-v and PRINT-en-v” /ˈɛnv ənd ˈprɪntˌɛnv/
Two commands that show the environment: env lists every environment variable with its value, and printenv prints the value of the ones you name.
What do env and printenv do?
env lists every environment variable your shell hands to the programs it starts, one NAME=value per line, so env | grep POWER checks whether POWER was exported. printenv with a name prints only that value. env can also start one program with an extra setting, as NAME=value command does.
env | grep POWER
printenv HOME USER SHELL
In a sentence
- “printenv HOME USER SHELL printed three lines: Sam's home folder, his user name and his shell.”
- “Sam piped env into grep POWER to check whether the variable had really been exported.”
Level: Apprentice · More Unix terms at this level
Updated