Environment Variable

Environment Variables - Shell Scripting

Environment Variables - Shell Scripting - 5.0 out of 5 based on 1 vote
User Rating:  / 1

All the environment variables will be declared in upper case and all local variables will be in lower case. This is the standard followed throughout the world.

HOME – will specify the home directory of the user

PATH – will specify the paths where it will search for commands

HOSTNAME – specifies the hostname of the server

SHELL – specifies the which shell is being used

PWD – specifies the current working directory

OLDPWD – specifies the previous working directory

Export Command:

export NEWENV=”success”

export is the command used to set an environmental variable

How to initialise environment variables during login?

Add the export command to .bash_profile or .profile file in your home directory. This file will be automatically executed during login, so the environment variables will be initialise when you login.

Printenv Command:

printenv | grep NEWENV

printenv is the command used to print all the environment variable.






You are here: Home Tutorials Shell Scripting Environment Variables