Skip to content

Instantly share code, notes, and snippets.

@pendashteh
Last active March 8, 2016 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pendashteh/8daf3528b7b9dc49d9df to your computer and use it in GitHub Desktop.
Save pendashteh/8daf3528b7b9dc49d9df to your computer and use it in GitHub Desktop.
Lists all the environmental variables and their values with the ability to filter by name.
#!/bin/sh
# Usage: list-vars.sh [regex_filter]
[ "$1" ] && filter=$1 || filter=".*"
vars=($(compgen -A variable | grep $filter))
for var in ${vars[@]}
do
eval "echo $var=\$$var"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment