只是喜欢记录、记录而已。
分类: LINUX
2016-07-08 13:52:01
|
Test Operator |
Test For |
|---|---|
|
String Test |
|
|
string1 = string2 |
String1 is equal to String2 (space surrounding = required) |
|
string1 != string2 |
String1 is not equal to String2 (space surrounding != required) |
|
string |
String is not null |
|
–z string |
Length of string is zero |
|
–n string |
Length of string is nonzero |
|
EXAMPLE test -n $word or [ -n $word ] test tom = sue or [ tom = sue ] |
|
|
Integer Test |
|
|
int1 –eq int2 |
Int1 is equal to int2 |
|
int1 –ne int2 |
Int1 is not equal to int2 |
|
int1 –gt int2 |
Int1 is greater than int2 |
|
int1 –ge int2 |
Int1 is greater than or equal to int2 |
|
int1 –lt int2 |
Int1 is less than int2 |
|
int1 –le int2 |
Int1 is less than or equal to int2 |
|
Logical Test |
|
|
expr1 -a expr2 |
Logical AND |
|
expr1 -o expr2 |
Logical OR |
|
! expr |
Logical NOT |
|
File Test |
|
|
–b filename |
Block special file |
|
–c filename |
Character special file |
|
–d filename |
Directory existence |
|
–f filename |
Regular file existence and not a directory |
|
–g filename |
Set-group-ID is set |
|
–k filename |
Sticky bit is set |
|
–p filename |
File is a named pipe |
|
–r filename |
File is readable |
|
–s filename |
File is nonzero size |
|
–u filename |
Set-user-ID bit is set |
|
–w filename |
File is writable |
|
–x filename |
File is executable |