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

首頁 > 系統 > Linux > 正文

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

2019-10-26 18:51:15
字體:
來源:轉載
供稿:網友

摘抄自: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的含義解釋就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 房产| 虎林市| 舞钢市| 壤塘县| 游戏| 普宁市| 镇平县| 团风县| 沅江市| 内丘县| 鹰潭市| 重庆市| 沅陵县| 丹寨县| 公主岭市| 石柱| 甘南县| 元谋县| 瓦房店市| 常山县| 方山县| 彩票| 泗水县| 静乐县| 榆林市| 庆安县| 黔西县| 兰坪| 蒙城县| 万州区| 无棣县| 叙永县| 黄冈市| 海宁市| 永城市| 吴忠市| 顺昌县| 阿拉尔市| 纳雍县| 曲水县| 和硕县|