国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Linux Shell > 正文

淺談linux中shell變量$#,$@,$0,$1,$2的含義解釋

2020-07-27 18:56:57
字體:
來源:轉載
供稿:網友

摘抄自:ABS_GUIDE

下載地址:http://www.tldp.org/LDP/abs/abs-guide.pdf

linux中shell變量$#,$@,$0,$1,$2的含義解釋:

變量說明:

$$
Shell本身的PID(ProcessID)
$!
Shell最后運行的后臺Process的PID
$?
最后運行的命令的結束代碼(返回值)
$-
使用Set命令設定的Flag一覽
$*
所有參數列表。如"$*"用「"」括起來的情況、以"$1 $2 … $n"的形式輸出所有參數。
$@
所有參數列表。如"$@"用「"」括起來的情況、以"$1" "$2" … "$n" 的形式輸出所有參數。
$#
添加到Shell的參數個數
$0
Shell本身的文件名
$1~$n

添加到Shell的各參數值。$1是第1參數、$2是第2參數…。

示例:

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
Have a nice day!!!

以上這篇淺談linux中shell變量$#,$@,$0,$1,$2的含義解釋就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 自治县| 邢台县| 通山县| 永和县| 宁强县| 清镇市| 蓬莱市| 芮城县| 天门市| 大方县| 扎赉特旗| 偃师市| 马鞍山市| 太湖县| 遂昌县| 彰化县| 泰兴市| 绍兴市| 五大连池市| 调兵山市| 永济市| 中卫市| 上饶县| 江华| 梅州市| 英德市| 依兰县| 临颍县| 甘肃省| 深州市| 金乡县| 师宗县| 阜康市| 两当县| 日土县| 垫江县| 曲阳县| 广水市| 贵阳市| 乾安县| 仁布县|