標籤:linux 字串 false equivalent
( EXPRESSION )
EXPRESSION is true EXPRESSION為真
! EXPRESSION
EXPRESSION is false EXPRESSION為假
EXPRESSION1 -a EXPRESSION2
both EXPRESSION1 and EXPRESSION2 are true 兩者都為真
EXPRESSION1 -o EXPRESSION2
either EXPRESSION1 or EXPRESSION2 is true 其中一個為真
-n STRING
the length of STRING is nonzero 字串長度非0
STRING equivalent to -n STRING
-z STRING
the length of STRING is zero 字串長度為0
STRING1 = STRING2
the strings are equal 字串相等
STRING1 != STRING2
the strings are not equal 字串不相等
INTEGER1 -eq INTEGER2
INTEGER1 is equal to INTEGER2 INTEGER1等於INTEGER2
INTEGER1 -ge INTEGER2
INTEGER1 is greater than or equal to INTEGER2 INTEGER1大於等於INTEGER2
INTEGER1 -gt INTEGER2
INTEGER1 is greater than INTEGER2 INTEGER1大於INTEGER2
INTEGER1 -le INTEGER2
INTEGER1 is less than or equal to INTEGER2 INTEGER1小於等於INTEGER2
INTEGER1 -lt INTEGER2
INTEGER1 is less than INTEGER2 INTEGER1小於INTEGER2
INTEGER1 -ne INTEGER2
INTEGER1 is not equal to INTEGER2 INTEGER1不等於INTEGER2
FILE1 -ef FILE2
FILE1 and FILE2 have the same device and inode numbers
FILE1 -nt FILE2
FILE1 is newer (modification date) than FILE2
FILE1 -ot FILE2
FILE1 is older than FILE2
-b FILE
FILE exists and is block special 檔案存在且為塊特殊檔案
-c FILE
FILE exists and is character special 檔案存在且為字元特殊檔案
-d FILE
FILE exists and is a directory 檔案存在且為目錄
-e FILE
FILE exists 檔案存在
-f FILE
FILE exists and is a regular file 檔案存在且為正規檔案
-g FILE
FILE exists and is set-group-ID 檔案存在且已設定組ID
-G FILE
FILE exists and is owned by the effective group ID 檔案存在且屬組為有效組ID
-h FILE
FILE exists and is a symbolic link (same as -L) 檔案存在且為符號連結
-k FILE
FILE exists and has its sticky bit set 檔案存在且已設定sticky-bit許可權
-L FILE
FILE exists and is a symbolic link (same as -h) 檔案存在且為符號連結
-O FILE
FILE exists and is owned by the effective user ID檔案存在且屬主為有效使用者ID
-p FILE
FILE exists and is a named pipe
-r FILE
FILE exists and read permission is granted 檔案存在且可讀
-s FILE
FILE exists and has a size greater than zero 檔案存在且大小非0
-S FILE
FILE exists and is a socket 檔案存在且是socket檔案
-t FD file descriptor FD is opened on a terminal
-u FILE
FILE exists and its set-user-ID bit is set 檔案存在且已設定set-user-id bit許可權
-w FILE
FILE exists and write permission is granted 檔案存在且可寫
-x FILE
FILE exists and execute (or search) permission is granted 檔案存在且可執行
Linux Shell Test