1748165 Members
4174 Online
108758 Solutions
New Discussion юеВ

Shell

 
Indrajit Bhagat
Regular Advisor

Shell

HI ALL,
WHAT ARE SHELL VARIABLES
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Shell

Hi:

Strictly speaking, "shell variables" are memory storage areas. That is, the variable or parameter is available only to the shell in which it is declared. Starting a subshell or another process does not inherit the variable. The variable is a 'local' one.

"Environmental" variables are 'global' variables. That is, they are visible by your current shell and any process started by it. The shell PATH, PS1, IFS, and HOME variables are examples of environmental ones.

"Shell variables" would also include the $0, $1...$n positional parameters, representing your program name and the arguments passed to it, respectively.

Shell variables include the $? which is the return value from the last command run; $# which is the number of positional parameters; and the $! which is the pid of the last background process.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Shell

Hi (again) Indrajit:

By the way, typing in all uppercase letters is considered to be shouting. It is generally regarded as rude. You should reserve its use for an occassional phrase for emphasis only, and then only rarely.

Regards!

...JRF...
Kodjo Agbenu
Honored Contributor

Re: Shell

Hi,

On a Linux box using standard "bash" shell, simply type "env" to see currently used shell variables.

Good lcuk.
Kodjo
Learn and explain...
Atul Gautam
Valued Contributor

Re: Shell

Hey IB,

Apart from using "env", you can also type "set" and you will see a listing of the environment variables that are set for the current session.




--
Atul