Location parameters
$0, $1, $2, etc. .. (note that when the number of parameters is greater than 9, you should reference $ {10}, ${11 }...)
Location parameter, which is passed to the script from the command line, to the function, or to a variable.
Example:
#! /Bin/bash </P> <p> # test. sh <br/> echo "first parameter $1" # first parameter of the output function or script <br/> echo "/$0 = $0" #$0 outputs the Function or the Script Name.
#./Test. Sh first second third
Output:
First parameter first
$0 =./test. Sh
When the number of parameters is greater than 9:
#! /Bin/bash </P> <p> # TT. sh </P> <p> echo "$0, $1, $2" <br/> echo "$10, $11 "# If You Want To reference 10 or 11 function or Script Parameters here, you will not get the expected results. <Br/> echo "$ {10}, $ {11}" # When the referenced parameter number is greater than 9, we need to enclose the number of parameters with braces.
#./TT. SH 0 1 2 3 4 5 6 7 8 9 11 22 33
Output:
./TT. SH 0 1
00 01 # There is no output parameter $10 value here, which is equivalent to the output value of $1, and then 0; the $11 following is equivalent to outputting the value of $1 first, and then outputting 1.
9 11
$ #
The number of command lines or location parameters. Simply put, it is the number of parameters included in a function or script.
$ *
All location parameters are used as a word.
Note: "$ *" must be referenced.
$ @
It is synonymous with $ *, but each parameter is an independent "" reference string, which means that the parameter is completely passed,
It is not interpreted and extended. This also means that each parameter in each parameter list is treated as an independent
Word.
Note: "$ @" must be referenced.