PATH and Shell Commands - serdarulutas/MADD-Notes GitHub Wiki
Introduction
printenv
printenv
prints environment variables. Example:
LOGNAME=serdarulutas
USER=serdarulutas
SHLVL=1
PWD=/Users/serdarulutas
OLDPWD=/Users
export
export
makes the variable available to the environment
example:
Step 1: export T_SCREENS=5
Step 2: export T_NUMBER_OF_LINES=10
Step 3: printenv
to verify that they are added to the variable list
Result:
GREP_COLORS=mt=37;45
T_SCREEN=5
T_NUMBER_OF_LINES=10
LANG=en_CA.UTF-8
echo
echo
can be used to display environmental variables
echo T
will return a blank text.
But echo $T_SCREEN
will return 5
, the value of the variable
Advanced topics
Exporting a variable.
export MESSAGE="HELLO"
export MESSAGE_COPY=$MESSAGE
Step 2 will grap the environment variable value "HELLO" and assign it to MESSAGE_COPY variable. Result is:
MESSAGE=HELLO
MESSAGECOPY=HELLO
LANG=en_CA.UTF-8
_=/usr/bin/printenv
PATH variable
echo $PATH
PATH
is used as a list of places where programs are installed. When a program is demanded by user, the OS looks into each folder described in PATH.