Explanation of the meaning of shell variables $#, $@, $0, $1, $2 in linux

Explanation of the meaning of shell variables $#, $@, $0, $1, $2 in linux: 
Variable description: 
$$ 
PID of Shell itself (ProcessID) 
$! 
The PID of the background Process that Shell runs  last
$? 
The end code of the last command to run (return value) 

-List of Flags set by Set command 
$*  List
of all parameters. For example, when "$*" is enclosed in """, all parameters are output in the form of "$1 $2 ... $n". 
$@ 
A list of all parameters. For example, when "$@" is enclosed in """, all parameters are output in the form of "$1" "$2" … "$n". 
$# 
The number of parameters added to the shell 
$0 
The file name of the shell itself 
$1~$n 
are added to each parameter value of the shell. $1 is the first parameter, $2 is the second parameter... . 
#!/bin/bash
printf "\$$ is $$ \n"
printf "\$! is $! \n"
printf "\$? is $? \n"
printf "\$- is $- \n"
printf "\$* is $* \n"
printf "\$@ is $@ \n"
printf "\$# is $# \n"
printf "\$0 is $0 \n"
printf "\$1 is $1 \n"
printf "\$2 is $2 \n"
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327100162&siteId=291194637