<tt>$1 $2 $3 ... $9, $*</tt>: Shell Parameters



next up previous contents
Next: $#: Number of Up: Parameters and the Previous: $0: The Name

$1 $2 $3 ... $9, $*: Shell Parameters

The first parameter to the shell is known as $1, the second as $2, etc. The collection of ALL parameters is known as $*.

Consider the following as an example:

    #!/bin/sh
    echo the first parameter is $1
    echo the second parameter is $2
    echo the collection of ALL parameters is $*
    exit 0
The output of that program could be:
prompt> prog first second
the first parameter is first
the second parameter is second
the collection of ALL parameters is first second
prompt>

Only nine parameters can be read using the $number scheme. The $* along with the shift instruction is one way to read the remainder of the parameters. Another way is to use the for var in $* command, to be seen in the upcoming Control Structures section.



Super-User
Fri Feb 17 15:55:40 EST 1995