1. $0, $1, $2, and so on: the location parameter is passed to the script from the command line, to the function, or to a variable.
The following is an example to illustrate what these three parameters are and give readers a perceptual knowledge.
1) Write shell scripts
#! /Bin/bashecho "$0 hahah, $1, $2" exit
2) Input sh tt8.sh 10 12 in the command line.
The running result is as follows:
Tt8.sh hahah, 10, 12
2. $ #: Number of command line or location parameters.
3. $ *: All location parameters are used as a word. Note: "$ *" must be referenced.
4. $ @: it is synonymous with $ *, but each parameter is an independent "" reference string. This means that the parameter is completely passed and is not interpreted or extended. this also means that each parameter in each parameter list is treated as an independent word. note: "$ @" must be referenced.
5. $-: falg passed to the script (use the set command ). note: This was initially a feature of ksh and was introduced to Bash, but unfortunately it does not seem reliable in Bash. one possible way to use this script is to test itself (check whether it is interactive ).
6. $! : The PID (process ID) of the final job running in the background ).
7. $ _: Save the last parameter of the previously executed command.
8. $? : Exit status of a command, function, or script
9. $: ID of the script's own process. This variable is often used to construct a temporary file name for "unique.