Bash environment variables

If you want to pull an environment variable into a bash script do

foo=$ENV_FOO;

To do the same, but assign foo a default value if there is no environment variable

foo=${ENV_FOO:-my_default_value}

Note: the - preceding the default value is required.

Leave A Reply
All content licensed under the Creative Commons License