日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux中sh+$0,浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释

發(fā)布時間:2025/3/20 linux 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux中sh+$0,浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

摘抄自:ABS_GUIDE

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

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

變量說明:

$$

Shell本身的PID(ProcessID)

$!

Shell最后運行的后臺Process的PID

$?

最后運行的命令的結(jié)束代碼(返回值)

$-

使用Set命令設(shè)定的Flag一覽

$*

所有參數(shù)列表。如"$*"用「"」括起來的情況、以"$1 $2 … $n"的形式輸出所有參數(shù)。

$@

所有參數(shù)列表。如"$@"用「"」括起來的情況、以"$1" "$2" … "$n" 的形式輸出所有參數(shù)。

$#

添加到Shell的參數(shù)個數(shù)

$0

Shell本身的文件名

$1~$n

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

示例:

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

結(jié)果:

[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變量$#,$2的含義解釋就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持編程小技巧。

總結(jié)

如果覺得編程之家網(wǎng)站內(nèi)容還不錯,歡迎將編程之家網(wǎng)站推薦給程序員好友。

本圖文內(nèi)容來源于網(wǎng)友網(wǎng)絡(luò)收集整理提供,作為學(xué)習(xí)參考使用,版權(quán)屬于原作者。

小編個人微信號 jb51ccc

喜歡與人分享編程技術(shù)與工作經(jīng)驗,歡迎加入編程之家官方交流群!

總結(jié)

以上是生活随笔為你收集整理的linux中sh+$0,浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。