標籤:linux $$
#!/bin/bash
#Created by ley on 2014-11-14
#Testing the Paramters
echo "The compleate list is %s\n" "$$"
echo "The compleate list is %s\n" "$!"
echo "The compleate list is %s\n" "$?"
echo "The compleate list is %s\n" "$*"
echo "The compleate list is %s\n" "[email protected]"
echo "The compleate list is %s\n" "$#"
echo "The compleate list is %s\n" "$0"
echo "The compleate list is %s\n" "$1"
echo "The compleate list is %s\n" "$2"
linux中shell變數$#,[email protected],$0,$1,$2的含義解釋:
變數說明:
$$
Shell本身的PID(ProcessID)
$!
Shell最後啟動並執行後台Process的PID
$?
最後啟動並執行命令的結束代碼(傳回值)
$-
使用Set命令設定的Flag一覽
$*
所有參數列表。如"$*"用「"」括起來的情況、以"$1 $2 … $n"的形式輸出所有參數。
[email protected]
所有參數列表。如"[email protected]"用「"」括起來的情況、以"$1" "$2" … "$n" 的形式輸出所有參數。
$#
添加到Shell的參數個數
$0
Shell本身的檔案名稱
$1~$n
添加到Shell的各參數值。$1是第1參數、$2是第2參數…。
[[email protected] ~]# ./params.sh 123456 QQ
The compleate list is %s\n 3406
The compleate list is %s\n
The compleate list is %s\n 0
The compleate list is %s\n 123456 QQ
The compleate list is %s\n 123456 QQ
The compleate list is %s\n 2
The compleate list is %s\n ./params.sh
The compleate list is %s\n 123456
The compleate list is %s\n QQ
本文出自 “linux營運分享” 部落格,請務必保留此出處http://liangey.blog.51cto.com/9097868/1576471
linux中shell變數$#,[email protected],$0,$1,$2的含義