国产探花免费观看_亚洲丰满少妇自慰呻吟_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的含義解釋就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙胜| 鲁山县| 徐水县| 茂名市| 始兴县| 金寨县| 汾西县| 廉江市| 九寨沟县| 黄浦区| 龙岩市| 桂平市| 炎陵县| 万州区| 雷州市| 伊金霍洛旗| 峡江县| 张家口市| 宝清县| 洮南市| 文昌市| 遂川县| 九龙县| 辉南县| 沙坪坝区| 宁武县| 阳春市| 郁南县| 阿勒泰市| 鄂伦春自治旗| 甘泉县| 鸡东县| 穆棱市| 玉门市| 榆中县| 珠海市| 金塔县| 山阳县| 漠河县| 诸暨市| 剑川县|