next up previous contents
Next: Special variables Up: Variables Previous: Environmental Variables   Contents

Shell Variables

Shell variables also hold numbers and character strings but, in contrast to environmental variables, their names are, by convention, lower case. Although they can also be used to customise the environment they are more normally used as part of shell programming. To create the variable myvar and store the character string ``abc'' in it, print it out, and then delete it again, from the Bourne shell:-

myvar="abc"
echo $myvar
unset myvar
while from the C shell:-
set myvar = "abc"
echo $myvar
unset myvar

Also in contrast to environmental variables, any process you run won't see these variables and so starts with a clean sheet, which again is typically what you want for a programming language. It may help to make things clearer if you think of environmental variables as global variables, that can be seen from every process, whereas shell variables are local, with each process having its own private copy. If you want all your processes to share a shell variable, there is a way to do it, by using the .cshrc file - see section 6.2.6


next up previous contents
Next: Special variables Up: Variables Previous: Environmental Variables   Contents
P.D. Gronbech (IT Staff) 2015-10-02