Linux variable \ $ #, \ $ @ \ $ 0, \ $ 1 \ $ 2 \ * $, $$, $? Meaning

  References:

  https://www.cnblogs.com/kaituorensheng/p/4002697.html

$ # Is the number of parameters passed to the script
$ 0 is the name of the script itself
$ 1 is the first argument passed to the shell script
$ 2 is the second parameter passed to the shell script
$ @ Is a list of all the parameters passed to the script
$ * Is a single string that is displayed all the different parameters passed to the script, and location variables, parameters can be more than 9
$$ script is running the current process ID number
$? Exit status of the last command is displayed, and 0 indicates no error, the other indicates an error

  example:

## dels.sh
echo "number:$#"
echo "scname:$0"
echo "first :$1"
echo "second:$2"
echo "argume:$@"
echo "show parm list:$*"
echo "show process id:$$"
echo "show precomm stat: $?"

  Results of the:

[@jihite]$ sh del.sh 1 2 3
number:3
scname: del.sh
first: 1
second:2
argume:1 2 3
show parm list:1 2 3
show process id:21057
show precomm stat: 0

Guess you like

Origin www.cnblogs.com/chester-cs/p/11915339.html