1748169 Members
4060 Online
108758 Solutions
New Discussion юеВ

Variables

 
Indrajit Bhagat
Regular Advisor

Variables

Hi Sir,
what is the purpose of variable, which are the different types of variables , how to manipulate it.
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Variables

Hi:

Based upon an earlier post of yours, I believe that your question relates to the shell.

Shell variables are valid only within the shell in which they are declared. Starting a subshell or another process does not inherit a variable from the parent shell or process. That is, the variable is a 'local' one, not a 'global' 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...
Steven E. Protter
Exalted Contributor

Re: Variables

Shalom,

variables are changeable, hence the name containers for data.

That is as simple and basic as I can put it.

env dipslays all set variables and that may help you understand what they are for.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
A. Clay Stephenson
Acclaimed Contributor

Re: Variables

Your question is all but meaningless without context. In general, a variable is by definition something that can be changed as opposed to a constant which is fixed.

It would help if you would narrow trhe scope of your question. Is is mathematical? Does it pertain to shell scripting? Perl? C? FORTRAN? Computer languages in general?

One very basic difference between computer languages and matmematics is that:

X = X + 1

is a perfectly valid computer statement but absolute nonsense in algebra. That is why without a scope, your question is all but impossible to answer.
If it ain't broke, I can fix that.
Torsten.
Acclaimed Contributor

Re: Variables

basic explanation (like the question):

http://en.wikipedia.org/wiki/Variable

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!