How To Print Environment Variables In Linux Unix

By admin ·
1

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

2

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
3

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

4

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
5

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

6

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
7

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

8

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
9

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

10

Use printenv to print all environment variables

printenv

This will print something like this:

...
rvm_bin_path=/Users/josephtyler/.rvm/bin
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josephtyler/.rvm/gems/ruby-2.2.0
SHELL=/bin/bash
...

This is a list of environment variable keys and values. There is one key/value pair per line.

11

Use printenv to print all environment variables

12

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
13

If a name is specified, only its value is printed

Still using printenv if you specify a name, then the value is printed (supposing it exists).

printenv RUBY_VERSION

will simply print:

ruby-2.2.0
14

If a name is specified, only its value is printed