COMMAND LINE ARGUMENTS

  • Inside a script the variables $1 $2 $3 etc. store the value of the command line arguments.

  • e.g. if a script called reg_vol is executed as:
    $ reg_vol im1 3 abc
    then $1 = im1, $2 = 3, $3 = abc

  • Other special variables are:
    • $0 = name of the script (often including the path)
    • $# = number of command line arguments given
    • $@ = all the command line arguments
              (i.e. $1 $2 $3 ...)
    • $$ = process ID number (unique to this process)