Name
test
Synopsis
testcondition
[condition
]
Evaluate a condition
and, if its value is
true, return a zero exit status; otherwise, return a nonzero exit
status. An alternate form of the command uses [ ] rather than the
word test. condition
is constructed using
the following expressions. Conditions are true if the description
holds true.
File conditions
- -a
file
file
exists.- -b
file
file
is a block special file.- -c
file
file
is a character special file.- -d
file
file
is a directory.- -e
file
file
exists.- -f
file
file
is a regular file.- -g
file
file
has the set-group-ID bit set.- -h
file
file
is a symbolic link.- -k
file
file
has its sticky bit (no longer used) set.- -p
file
file
is a named pipe (FIFO).- -r
file
file
is readable.- -s
file
file
has a size greater than 0.- -t [n]
The open file descriptor n is associated with a terminal device (default
n
is 1).- -u
file
file
has its set-user-ID bit set.- -w
file
file
is writable.- -x
file
file
is executable.- -G
file
file
’s group is the process’s effective GID.- -L
file
file
is a symbolic link.- -N
file
file
has been modified since its last time of access.- -O
file
file
’s owner is the process’s effective UID.- -S
file
file
is a socket.-
f1
-eff2
Files
f1
andf2
are linked (refer to the same file through a hard link).-
f1
-ntf2
File
f1
is newer thanf2
.-
f1
-otf2
File
f1
is older thanf2
.
String conditions
- -n
s1
String
s1
has nonzero length.- -o
s1
Shell option
s1
is set. Shell options are described under the set built-in command.- -z
s1
String
s1
has 0 length. ...
Get Mac OS X Panther in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.