$: The script name, relative path, or absolute path depends on how the call is being invoked. If the./dollartest.sh call is in the parent directory, then $ is./dollartest.sh, if it is a full path call, such as "/root/test/dollartest.sh", then $ is "/root/test/ Dollartest.sh ". $n: The nth argument of the invocation. PS: If n > 9, the number needs to be enclosed in parentheses, such as ${10}, otherwise the shell interpreter would think that the number is $1. $*: All parameters in the script. $@: With $*.
$#: The number of parameters for the script. $$: Change the process number when the shell script executes. $?: The output of the previous command, if the return value of the previous command exit. $!: The PID number that was executed by the previous background process.!$: Last string of previous command. $-: The flag set by using the SET command.
To run the script dollartest.sh, for example, script code:
#!/bin/bash Echo ' $ is ' $ ' is ' $ ' ' is ' ' $11 ', ' is ' ' The Echo ', '
${11}
Echo ' $# is ' $#
echo ' $* is ' $*
echo ' $@ is ' $@
echo ' $$ are ' $$
sh test.sh # This shell script'll exit with one
Echo ' $ is ' $?
echo ' $# is ' $#
nohup ping www.baidu.com &
Echo ' $! is ' $!
Echo $-
Because there are special characters, display is not complete, so use the picture display shell source code;
Run commands and Parameters:./dollartest.sh 1 2 3 4 5 6 7 8 9 10 21 22 23 24 Execution Results: