shell test的用法,轉過來以備查閱

1)判斷表達式 if test  (表達式爲真) if test !表達式爲假 test 表達式1 –a 表達式2                  兩個表達式都爲真 test 表達式1 –o 表達式2                 兩個表達式有一個爲真 2)判斷字符串 test –n 字符串                                   字符串的長度非零 test –z 字符串                                    字符串的長度爲零 test 字符串1=字符串2                    字符串相等 test 字符串1!=字符串2               字符串不等 3)判斷整數 test 整數1 –eq 整數2                        整數相等 test 整數1 –ge 整數2                        整數1大於等於整數2 test 整數1 –gt 整數2                         整數1大於整數2 test 整數1 –le 整數2                         整數1小於等於整數2 test 整數1 –lt 整數2                          整數1小於整數2 test 整數1 –ne 整數2                        整數1不等於整數2 4)判斷文件 test  File1 –ef  File2                            兩個文件具備一樣的設備號和i結點號 test  File1 –nt  File2                            文件1比文件2 新 test  File1 –ot  File2                            文件1比文件2 舊 test –b File                                           文件存在而且是塊設備文件 test –c File                                           文件存在而且是字符設備文件 test –d File                                           文件存在而且是目錄 test –e File                                           文件存在 test –f File                                            文件存在而且是正規文件 test –g File                                           文件存在而且是設置了組ID test –G File                                           文件存在而且屬於有效組ID test –h File                                           文件存在而且是一個符號連接(同-L) test –k File                                           文件存在而且設置了sticky位 test –b File                                           文件存在而且是塊設備文件 test –L File                                           文件存在而且是一個符號連接(同-h) test –o File                                           文件存在而且屬於有效用戶ID test –p File                                           文件存在而且是一個命名管道 test –r File                                            文件存在而且可讀 test –s File                                           文件存在而且是一個套接字 test –t FD                                             文件描述符是在一個終端打開的 test –u File                                           文件存在而且設置了它的set-user-id位 test –w File                                          文件存在而且可寫 test –x File                                           文件存在而且可執行

相關文章
相關標籤/搜索