kxbin
          成功留給有準(zhǔn)備的人
          posts - 10,  comments - 35,  trackbacks - 0
          linux中shell變量$#,$@,$0,$1,$2的含義解釋(jieshi): 
          變量說明(shuoming): 
          $$ 
          Shell本身(benshen)的PID(ProcessID) 
          $! 
          Shell最后(zuihou)運(yùn) 行(running)的后臺(tái)Process的PID 
          $? 
          最后(zuihou)運(yùn) 行(running)的命令的結(jié)束(jieshu)代碼(返回(fanhui)值) 
          $- 
          使用(shiyong)Set命令設(shè)定的Flag一覽 
          $* 
          所有(suoyou)參數(shù)列表。如"$*"用「"」括起來的情況(qingkuang)、以"$1 $2 … $n"的形式(xingshi)輸出(shuchu)所有(suoyou)參數(shù)。 
          $@ 
          所有(suoyou)參數(shù)列表。如"$@"用「"」括起來的情況(qingkuang)、以"$1" "$2" … "$n" 的形式(xingshi)輸出(shuchu)所有(suoyou)參數(shù)。 
          $# 
          添加(tianjia)到Shell的參數(shù)個(gè)數(shù) 
          $0 
          Shell本身(benshen)的文件名 
          $1~$n 
          添加(tianjia)到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é)果(jieguo):

          [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 
          posted on 2012-04-24 23:24 kxbin 閱讀(483) 評(píng)論(0)  編輯  收藏 所屬分類: Linux
          你恨一個(gè)人是因?yàn)槟銗鬯荒阆矚g一個(gè)人,是因?yàn)樗砩嫌心銢]有的;你討厭一個(gè)人是因?yàn)樗砩嫌心阌械臇|西;你經(jīng)常在別人面前批評(píng)某人,其實(shí)潛意識(shí)中是想接近他。

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(5)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          J2EE

          java技術(shù)網(wǎng)站

          Linux

          平時(shí)常去的網(wǎng)站

          數(shù)據(jù)庫

          電影網(wǎng)站

          網(wǎng)站設(shè)計(jì)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 黎城县| 蒙自县| 增城市| 蓬莱市| 敦化市| 福贡县| 泸溪县| 垣曲县| 杨浦区| 汨罗市| 东辽县| 固镇县| 浠水县| 天全县| 米易县| 师宗县| 凤冈县| 贵州省| 慈溪市| 卫辉市| 高平市| 扶绥县| 安宁市| 蒙阴县| 卢湾区| 勐海县| 赣州市| 伽师县| 婺源县| 贵德县| 周宁县| 安化县| 观塘区| 新民市| 资阳市| 理塘县| 重庆市| 兴仁县| 噶尔县| 富平县| 墨脱县|