How to get an environment variable in Bash?

In Bash, how to get the value (string) of an environment variable?

In Bash, just directly use:


Note that if you assigned a value to the “local” variable $VAR in your program before reading the “environmental” $VAR, the $VAR will actually contain the value you assigned.

Leave a Reply

Your email address will not be published. Required fields are marked *