Variable Function
$0 script name
Access $1 ~ $9 arguments, $1 for the first argument, $2 for the second argument
$ # number of arguments given to the script
$ * treat all arguments together as one
$ @ Thread all arguments as separate
$? End value of the last executed command (0 is success, 1 is failure)
$$ Process ID of this shell script
$! last executed background process ID
#!/bin/sh echo "\$0 (スクリプト名): $0" echo "\$1 (1番目の引数): $1" echo "\$2 (2番目の引数): $2" echo "\$# (引数の数): $#" echo "\"\$*\": \"$*\"" echo "\"\$@\": \"$@\"" VAR="exit値は0になるはずです" echo $?
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
$0 (スクリプト名): ./test.sh
$1 (1番目の引数):
$2 (2番目の引数):
$# (引数の数): 0
“$*”: “”
“$@”: “”
0