The execution name of this program
$n the nth parameter value of this program, n=1..9
$* all parameters of this program, this option can have more than 9 parameters.
$# the number of parameters for this program
$$ the PID of this program (the current process ID number of the script run)
$! PID of the previous background instruction (process ID number of the last process running in the background)
$? Executes the return value of the previous instruction (displays the exit status of the last command. 0 means no error, any other value indicates an error)
$-shows the current options used by the shell, same as the SET command function
[email protected] is similar to $*, but can be used as an array
Example:
1 #!/bin/bash 2 # 3 printf "The complete list is %s\n" "$$" 4 printf "The complete list is %s\n" "$!" 5 printf "The complete list is %s\n" "$?" 6 printf "The complete list is %s\n" "$*" 7 printf "The complete list is %s\n" "[email protected]" 8 printf "The complete list is %s\n" "$#" 9 printf "The complete list is %s\n" "$0" 10 printf "The complete list is %s\n" "$1" 11 printf "The complete list is %s\n" "$2 |
Results:
[[email protected] ~]$ bash params .sh 123456 QQ The complete list is 24249 The complete list is The complete list is 0 The complete list is 123456 QQ The complete list is 123456 The complete list is QQ The complete list is 2 The complete list is params .sh The complete list is 123456 The complete list is QQ |
Meaning of variables $$, $ A, etc. in shell scripts