Table of Contents
We need to discuss a little more on parameters.
Remember we've seen parameters $0..$9 and $# which is the number of parameters, $? the exit status of the previous command, etc.
What we need to discuss is the nifty ways of manipulating our parameters. For the purposes of this chapter we're going to set a variable called MAGIC:
MAGIC='abracadabra' |
Check that it is set.
echo "The magic word is $MAGIC" |
or we could use an equivalent command:
echo "The magic word is ${MAGIC}" |
This should produce:
The magic word is abracadabra |
We can also test whether the MAGIC variable is set by:
echo ${MAGIC}X=${MAGIC} |
If you go a couple of chapters back to your conditional constructs, you'll see that we used this command to check whether the variable MAGIC was set.
The echo produces:
abracadaraX=abracadabra |
which was FALSE(1).