10. Variables - Part IIThere are a set of variables which are
set for you already, and most of these cannot have values
assigned to them. These can contain useful information, which
can be used by the script to know about the environment in which
it is running. The first set of variables we will look at are $0
.. $9 $0 is the basename of the program as it $1 .. $9 are the
first 9 additional parameters the script was called with. $@ is
all parameters $1 .. whatever. $*, is similar, but does not
preserve any whitespace, and quoting, so "File with spaces"
becomes "File" "with" "spaces". This is similar to echo stuff we
looked at in A First Script. As a general rule, use $@ and avoid
$# is the number of parameters the script was called with. Let's
take an example script: #!/bin/sh echo "I was called with $#
parameters" echo "My name is $0" echo "My first parameter is $1"
echo "My second parameter is $2" echo "All parameters are $@"
Let's look at running this code and see the output: $
/home/steve/var3.sh I was ca