Test Command
$ test expression or
$ [ expression ]
|
-r file
|
true if file exists and is
readable
|
-w file
|
true if file exists and is
writable
|
-x file
|
true if file exists and is
executable
|
-f file
|
true if file exists and is
a regular file
|
-d file
|
true if file exists and is
a directory
|
-c file
|
true if file exists and is
a character special file
|
-b file
|
true if file exists and is
a block special file
|
-p file
|
true if file exists and is
a named pipe special file
|
-u file
|
true if file exists and
has set-user-id bit set
|
-g file
|
true if file exists and
has set-group-id bit set
|
-k file
|
true if file exists and
has sticky bit set
|
-s file
|
true if file exists and
has a size greater than zero
|
-t [filedes]
|
true if the open file in
slot fildes (file descriptor) is associated with a terminal
|
-z s1
|
true if the length of
string s1 is zero
|
-n s1
|
true if the length of
string s1 is non-zero
|
s1 = s2
|
true if strings s1 and s2
are identical
|
s1 != s2
|
true if strings s1 and s2
are not identical
|
s1
|
true if s1 is not the null
string
|
n1 -eq n2
|
true if the integers n1
and n2 are algebraically equal
-lt less than
-le less than or equal
-gt greater than
-ge greater than or equal
-ne not equal
-eq equal
|
!
|
negation
|
-a
|
binary and
|
-o
|
binary or (-a has higher
precedence)
|
(expression)
|
parentheses for grouping
|