久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      Shell腳本語法解析

      數(shù)值運算:
      1.給變量a,b賦值 [root@localhost ~]# a=11
      [root@localhost ~]# b=22
      a與b相加: [root@localhost ~]# d=(expr" role="presentation">

      (expr

      a + $b)
      注意:“ + ”號左右兩側必須有空格
      2.表達式求值:
      expr1+3" role="presentation">

      expr1+3

      expr 2 – 1
      expr13使" role="presentation">

      expr13使

      echo expr 1 + 3
      注意:表達式中,數(shù)字和運算符指教要有空格,出現(xiàn)在語句中要加反引號
      3.“(())" role="presentation">

      (())

      [運算式]”
      [root@localhost ~]# a=11
      [root@localhost ~]# b=22
      [root@localhost ~]# g=[" role="presentation">

      [

      a + b ]     4.[root@localhost ~]# a=" role="presentation">b]
      4.[root@localhost~]#a=

      b]4.[root@localhost~]#a=

      (( (11+3)*3/2 ))
      雖然乘和除的優(yōu)先級高于加,但是通過小括號可以調整運算優(yōu)先級
      5.[root@localhost ~]# b=$(( 14%3 ))
      14 不能被 3 整除,余數(shù)是 2
      變量表達式:
      1. 條件判斷命令test:test n1 -參數(shù) n2(或 –參數(shù) 表達式) 真返回0,假返回1。
      test語句的等價形式[ 1 –lt 4 ]
      可用中括號代替test,把表達式括起來實現(xiàn)判斷
      注意表達式與中括號間有空格
      1.1. 整數(shù),比較運算符 -lt 小于 -le 小于等于 -gt 大于
      -ge 大于等于 -eq 等于 -ne 不等于
      1.2. 文件測試 -f 存在且是普通文件 -d 存在且是目錄
      -s 存在且字節(jié)數(shù)大于0 -r 存在且可讀
      -w 存在且可寫 -x 存在且可執(zhí)行
      如:test -d “mydoc” 判斷mydoc是否是目錄
      2. 字符串測試 : test s 字符串s非空
      test s1 = s2 字符串s1等于s2 test s1 != s2 字符串s1不等于s2
      test -z s字符串長=0,即為空串 test -n 字符串長>0
      3. 其他參數(shù)
      -a 邏輯與 -o邏輯或 ! 邏輯非
      控制流程:
      1. 分支結構
      1.1. if分支
      if [ # -eq 0 ]                         then                            echo “輸入了0個參數(shù)”                     elif [" role="presentation">#-eq0]
      then
      echo“輸入了0個參數(shù)”
      elif[

      #-eq0]thenecho“輸入了0個參數(shù)”elif[

      # -gt 1 ]
      then
      echo “輸入了多個參數(shù)”
      else
      echo “輸入了1個參數(shù)”
      fi
      1.2. case
      case “$#” in
      0) echo “輸入了0個參數(shù)” ;;
      1) echo “輸入了1個參數(shù)” ;;
      *) echo “輸入了多個參數(shù)”;;
      esac
      每個分支條件后必須以兩個分號結尾
      2. 循環(huán)結構
      for 例子——輸出100內(nèi)10的倍數(shù)
      for i in seq 1 9
      do
      echo expr $i * 10
      done
      乘號前加轉義符,與數(shù)字間要有空格
      #for i in {1..9} #大括號中不能有變量
      3. read 變量1 [變量2 …]
      鍵盤上讀取多個變量的值,或輸入數(shù)據(jù)時,以空格或者Tab鍵作為分隔。
      如果輸入的數(shù)據(jù)個數(shù)不夠,則從左到右對應賦值,沒有輸入的變量為空;
      如果輸入的數(shù)據(jù)個數(shù)超了,則從左到右對應賦值,最后一個變量被賦予剩余的所 有數(shù)據(jù)。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號