$0 這個程式的執行名字示例:$n 這個程式的第n個引數值,n=1..9
$* 這個程式的所有引數,此選項引數可超過9個。
$# 這個程式的引數個數
$$ 這個程式的pid(指令碼執行的當前程序id號)
$! 執行上乙個背景指令的pid(後台執行的最後乙個程序的程序id號)
$? 執行上乙個指令的返回值 (顯示最後命令的退出狀態。0表示沒有錯誤,其他任何值表明有錯誤)
$- 顯示shell使用的當前選項,與set命令功能相同
$@ 跟$*類似,但是可以當作陣列用
1 #!/bin/bash
2 #
3 printf
"the complete list is %s\n"
"$$"
4 printf
"the complete list is %s\n"
"$!"
5 printf
"the complete list is %s\n"
"$?"
6 printf
"the complete list is %s\n"
"$*"
7 printf
"the complete list is %s\n"
"$@"
8 printf
"the complete list is %s\n"
"$#"
9 printf
"the complete list is %s\n"
"$0"
10 printf
"the complete list is %s\n"
"$1"
11 printf
"the complete list is %s\n"
"$2
結果:[aric@localhost ~]$ bash
params
.sh 123456 qq
the complete list
is
24249
the complete list
is
the complete list
is
0
the complete list
is
123456 qq
the complete list
is
123456
the complete list
is
qq
the complete list
is
2
the complete list
is
params
.sh
the complete list
is
123456
the complete list
is
qq
shell指令碼中 0 等特殊變數的含義
bin shecho echo 0 0 echo 1 1 echo 2 2 echo echo echo echo 儲存指令碼為 test.sh,來看下執行結果 從結果我們可以看出 傳給指令碼的引數個數 0 指令碼本身的名字 1 傳遞給該shell指令碼的第1個引數 2 傳遞給該shell指令碼的第...
Shell指令碼中 0, , 等含義
shell本身的pid processid shell最後執行的後台process的pid 最後執行的命令的結束 返回值 使用set命令設定的flag一覽 所有引數列表。如 用 括起來的情況 以 1 2 n 的形式輸出所有引數。所有引數列表。如 用 括起來的情況 以 1 2 n 的形式輸出所有引數。...
Shell指令碼中 0 等的意義
變數說明 shell本身的pid processid shell最後執行的後台process的pid 最後執行的命令的結束 返回值 使用set命令設定的flag一覽 所有引數列表。如 用 括起來的情況 以 1 2 n 的形式輸出所有引數。所有引數列表。如 用 括起來的情況 以 1 2 n 的形式輸出...