$0 $1 表示第幾個參數,在awk中以$1開始計shell
$# 參數個數函數
$* 全部位置參數做爲一個單詞code
$@ 與$*同義,但每個參數都是一個獨立的「引用字符串」,推薦使用$@three
$_ 以前執行的命令的最後一個參數字符串
$? 命令、函數或者腳本自己的退出狀態ast
$$ 腳本自身的PID,可用於構造一個「unique」的臨時文件名class
示例:test
test.sh:awk
echo "the total number of parameters is $#" echo "the name of shell file is $0" echo "the total parameters using \$*: $*" echo "the total parameters using \$@: $@" echo "arg in \"\$*\"" for arg in "$*" do echo $arg done echo "arg in \"\$@\"" for arg in "$@" do echo $arg done echo "the last parameter is $_" echo "the shell pid id $$"
運行:chmod 777 test.sh ; ./test.sh one two threefile
輸出:
the total number of parameters is 3 the name of shell file is ./test.sh the total parameters using $*: one twothree the total parameters using $@: one twothree arg in "$*" one two three arg in "$@" one two three the last parameter is three theshell pid id 27635