中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Linux基礎(chǔ)系列之判斷符在shell中的使用方式

        Linux基礎(chǔ)系列之判斷符在shell中的使用方式

        作者: 時(shí)間:2012-07-25 來(lái)源:網(wǎng)絡(luò) 收藏

        1. 關(guān)于某個(gè)檔名的『類(lèi)型』偵測(cè)(存在與否),如 test -e filename

        本文引用地址:http://www.antipu.com.cn/article/148719.htm

        -e 該『檔名』是否存在?(常用)

        -f 該『檔名』是否為檔案(file)?(常用)

        -d 該『文件名』是否為目錄(directory)?(常用)

        -b 該『文件名』是否為一個(gè) block device 裝置?

        -c 該『文件名』是否為一個(gè) character device 裝置?

        -S 該『檔名』是否為一個(gè) Socket 檔案?

        -p 該『檔名』是否為一個(gè) FIFO (pipe) 檔案?

        -L 該『檔名』是否為一個(gè)連結(jié)檔?

        2. 關(guān)于檔案的權(quán)限偵測(cè),如 teST -r filename

        -r 偵測(cè)該文件名是否具有『可讀』的屬性?

        -w 偵測(cè)該檔名是否具有『可寫(xiě)』的屬性?

        -x 偵測(cè)該檔名是否具有『可執(zhí)行』的屬性?

        -u 偵測(cè)該文件名是否具有『SUID』的屬性?

        -g 偵測(cè)該文件名是否具有『SGID』的屬性?

        -k 偵測(cè)該文件名是否具有『Sticky bit』的屬性?

        -s 偵測(cè)該檔名是否為『非空白檔案』?

        3. 兩個(gè)檔案之間的比較,如: test file1 -nt file2

        -nt (newer than) file1 是否比 file2 新

        -ot (older than) file1 是否比 file2 舊

        -ef file2 與 file2 是否為同一檔案,可用在判斷 hard link 的判定上。 主要意義在判定,兩個(gè)檔案是否均指向同一個(gè) inode 哩!

        4. 關(guān)于兩個(gè)整數(shù)之間的判定,例如 test n1 -eq n2

        -eq 兩數(shù)值相等 (equal)

        -ne 兩數(shù)值不等 (not equal)

        -gt n1 大于 n2 (greater than)

        -lt n1 小于 n2 (less than)

        -ge n1 大于等于 n2 (greater than or equal)

        -le n1 小于等于 n2 (less than or equal)

        5. 判定字符串的數(shù)據(jù)

        test -z string 判定字符串是否為 0 ?若 string 為空字符串,則為 true

        test -n string 判定字符串是否非為 0 ?若 string 為空字符串,則為 false。

        注: -n 亦可省略

        test str1 = str2 判定 str1 是否等于 str2 ,若相等,則回傳 true

        test str1 != str2 判定 str1 是否不等于 str2 ,若相等,則回傳 false

        6. 多重條件判定,例如: test -r filename -a -x filename

        -a (and)兩狀況同時(shí)成立!例如 test -r file -a -x file,則 file 同時(shí)具有 r 與 x 權(quán)限時(shí),才回傳 true。

        -o (or)兩狀況任何一個(gè)成立!例如 test -r file -o -x file,則 file 具有 r 或 x 權(quán)限時(shí),就可回傳 true。

        ! 反相狀態(tài),如 test ! -x file ,當(dāng) file 不具有 x 時(shí),回傳 true

        linux操作系統(tǒng)文章專題:linux操作系統(tǒng)詳解(linux不再難懂)


        評(píng)論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉