freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

[計算機硬件及網絡]linux的shell編程-文庫吧

2025-09-17 23:05 本頁面


【正文】 rst export FILM 在調用腳本前導出變量 ./child echo back to father echo and the film is :$FILM 輸出結果 $ ./father2 this is the father I like the film :A Few Good Men called from father..i am the child film is :A Few Good Men changing film to :Die Hard back to father and the film is :A Few Good Men 位置變量參數 ? 如果要向一個 shell腳本傳遞信息,可以使用位置參數完成此功能。參數相關數目傳入腳本,此數目可以任意多,但只有前 9個可以被訪問,使用 shift命令可以改變這個限制。 ? 參數從第 1個開始,在第 9個結束;每個訪問參數前要加 $符號。第一個參數為 0,表示預留保存實際腳本名字。 位置變量參數(續(xù)) ? 如向腳本傳送 Did You See The Full Moon信息: $0 $1 $2 $3 $4 $5 $6 腳本名字 Did You See The Full Moon $7 $8 $9 (1) 在腳本中使用位置參數 $cat param !/bin/sh param echo This is the script name : $0 echo This is the first parameter: $1 echo This is the 2nd parameter : $2 echo This is the third parameter: $3 echo This is the 6th parameter : $6 echo This is the 7th parameter : $7 輸出結果 執(zhí)行: $ ./param Did You See The Full Moon This is the script name : ./param This is the first parameter: Did This is the 2nd parameter : You This is the third parameter: See This is the 6th parameter : Moon This is the 7th parameter : (2) 向系統(tǒng)命令傳遞參數 $cat findfile !/bin/sh findfile find / name $1 –print 預定義變量 ? 預定義變量是在 shell一開始時就定義了的變量,用戶不能重定義它。所有預定義變量都是由 $符和另一個符號組成的。 ? 常用的預定義變量: $ 傳遞到腳本的參數個數 $* 以一個單字符串顯示所有向腳本傳遞的參數 。與位置變量不同 , 此選項參數可超過 9個 $$ 腳本運行的當前進程 ID號 預定義變量(續(xù)) $! 后臺運行的最后一個進程的進程 ID號 $@ 與 $ 相同 , 但是使用時加引號 , 并在引號中返回每個參數 $ 顯示 shell使用的當前選項 , 與 set命令功能相同 $? 顯示最后命令的退出狀態(tài)。 0表示沒有錯誤,其他任何值表明有錯誤。 (1) 最后的退出狀態(tài) $ cp /tmp $ echo $? 0 $ cp /usr/bin/aaa/bbb cp: cannot create regular file 39。/usr/bin/aaa/bbb39。: No such file or directory $ echo $? 1 ( 1) 測試文件狀態(tài) t e s t一般有兩種格式,即: test condition 或 [ condition ] 使用方括號時,要注意在條件兩邊加上空格。 測試文件狀態(tài) (續(xù)) r文件名:如果文件存在且可讀則為真 w文件名:如果文件存在且可寫則為真 x文件名:如果文件存在且可執(zhí)行則為真 s文件名:如果文件存在且至少有一個字符則為真 d文件名:如果文件存在且為目錄則為真 f文件名:如果文件存在且為普通文件則為真 e文件名:如果文件存在則為真 c文件名:如果文件存在且為字符型特殊文件則為真 b文件名:如果文件存在且為塊特殊文件則為真 測試文件 是否可寫 $ls –l rwr—r 1 dave admin 0 May 15 11:29 $[ w ] $echo $? 0 $test –w $echo $? 0 簡單的算術運算 格式: $[expression] 例如: var1=2 var2=$[var1*10+1] 則: var2的值為 21。 數值數據處理 Bash提供了 3種方法對數值型數據進行算術運算: ( 1)使用 let命令 ( 2)使用 shell擴展 $((expression)) ( 3)使用 expr命令 ( 1) let命令 語法: let expresslist 功能:求出算術表達式的值 如果最后的表達式取值為 0,則 let命令返回1;否則返回 0。 $let ―a=8‖ ―b=13‖ 命令中的表達式含空格,需加雙引號 $let c=a+b $echo ―The value of c is $c.‖ The value of c is 21. $let ―a *= b‖ $echo ―The new value of a is $a。 the product of a and b.‖ The new value of a is 104。 the product of a and b. Bash擴展 語法: $((expression)) 功能:計算 expression并返回它的值 $a=8 b=13 $echo ―The new value of c is $((a+b)) .‖ The new value of c is 21. expr命令 語法: expr args 功能:計算 args的值,并返回它的值到標準輸出 $var1=10 $var1=?expr $var1 + 1‘ $echo $var1 11 (2)測試時使用邏輯操作符號 Shell提供了三種邏輯操作完成兩個文件狀態(tài)比較的功能 a 邏輯與 o 邏輯或 ! 邏輯否 測試兩個文件是否均可寫 $[ w –a –w ] $echo $? 0 (3)字符串測試 字符串測試共包含五種格式: test ―string‖ test string_operator ―string‖ test ―string‖ string_operator ―string‖ [ string_operator string ] [ string string_operator string ] String_operator 可以為: =:兩個字符串相等 !=:兩個字符串不等 z: 空串 n: 非空串 比較兩個字符串是否相等 $TAPE1=‖/dev/rmt0‖ $TAPE2=‖dev/rmt1‖ $[ ―$TAPE1‖ = ―$TAPE2‖] $echo $? 1 (4)數值測試 格式: “ number‖ numeric_operator ―number‖ 或 [ “ number‖ numeric_operator ―number‖ ] numeric_operat
點擊復制文檔內容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1