exploring the terminal: printenv and env

2020-01-28

 | 

~1 min read

 | 

159 words

Today, I’m diving a little further down the environment variables hole I started yesterday when looking into how environment variables are sourced. As usual, this meant learning new things. Today it was about two commands env and printenv.

These utilities are quite useful for quickly visualizing your current environment and the variable assignment.

Without arguments, the output is very similar.

This Stackexchange.com answer walks through the history of how we arrived at two utilities that perform similar functions.

Bottom line: These utilities provide a nice, ergonomic alternative to an echo command to see the value of an environment variable.

$ echo $MY_DB_USER
sweiss
$ env | grep USER
sweiss
$ printenv | grep USER
sweiss

By ergonomic, I mean that with env or printenv, you don’t need to know the entire variable up front, making it easier to find what you’re looking for.

Sometimes, it’s these little things that make all the difference for the development experience.



Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!