婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Shell 函數(shù)參數(shù)

Shell 函數(shù)參數(shù)

熱門標(biāo)簽:杭州機(jī)器人外呼系統(tǒng) 百度地圖的地圖標(biāo)注 excel地址地圖標(biāo)注 地圖標(biāo)注超出范圍怎么辦 佛山高德地圖標(biāo)注中心 百度地圖標(biāo)注圖標(biāo)更換 旅游地圖標(biāo)注大全 東莞電銷機(jī)器人價格一覽表 陜西電銷卡外呼系統(tǒng)怎么安裝

在shell中,調(diào)用函數(shù)時可以向其傳遞參數(shù)。在函數(shù)體內(nèi)部,通過 $n 的形式來獲取參數(shù)的值,例如,$1表示第一個參數(shù),$2表示第二個參數(shù)...

帶參數(shù)的函數(shù)示例:

#!/bin/bash
funWithParam(){
  echo "The value of the first parameter is $1 !"
  echo "The value of the second parameter is $2 !"
  echo "The value of the tenth parameter is $10 !"
  echo "The value of the tenth parameter is ${10} !"
  echo "The value of the eleventh parameter is ${11} !"
  echo "The amount of the parameters is $# !"
  echo "The string of the parameters is $* !"
}
funWithParam 1 2 3 4 5 6 7 8 9 34 73

輸出:

The value of the first parameter is 1 !
The value of the second parameter is 2 !
The value of the tenth parameter is 10 !
The value of the tenth parameter is 34 !
The value of the eleventh parameter is 73 !
The amount of the parameters is 12 !
The string of the parameters is 1 2 3 4 5 6 7 8 9 34 73 !"

注意,$10 不能獲取第十個參數(shù),獲取第十個參數(shù)需要${10}。當(dāng)n>=10時,需要使用${n}來獲取參數(shù)。

另外,還有幾個特殊字符用來處理參數(shù):

參數(shù)處理 說明
$# 傳遞到腳本的參數(shù)個數(shù)
$* 以一個單字符串顯示所有向腳本傳遞的參數(shù)
$$ 腳本運行的當(dāng)前進(jìn)程ID號
$! 后臺運行的最后一個進(jìn)程的ID號
$@ 與$#相同,但是使用時加引號,并在引號中返回每個參數(shù)。
$- 顯示Shell使用的當(dāng)前選項,與set命令功能相同。
$? 顯示最后命令的退出狀態(tài)。0表示沒有錯誤,其他任何值表明有錯誤。

您可能感興趣的文章:
  • Shell腳本函數(shù)定義和函數(shù)參數(shù)

標(biāo)簽:青島 朝陽 通遼 雅安 延邊 隨州 南充 西藏

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Shell 函數(shù)參數(shù)》,本文關(guān)鍵詞  Shell,函數(shù),參數(shù),Shell,函數(shù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Shell 函數(shù)參數(shù)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Shell 函數(shù)參數(shù)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 措美县| 嘉荫县| 兴和县| 揭西县| 库车县| 天门市| 文安县| 德阳市| 孙吴县| 衡东县| 漳平市| 丹巴县| 阳新县| 库尔勒市| 兖州市| 奉化市| 垦利县| 靖安县| 衡南县| 中方县| 闽清县| 锦州市| 红桥区| 富锦市| 克什克腾旗| 博爱县| 望奎县| 吉木萨尔县| 固原市| 图片| 宁南县| 松滋市| 札达县| 南平市| 莆田市| 周宁县| 陵川县| 读书| 沙坪坝区| 舞钢市| 正镶白旗|