O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

test

Synopsis

                     
                        test
                      
                     condition
                     
                        [
                      
                     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 -ef f2

Files f1 and f2 are linked (refer to the same file through a hard link).

f1 -nt f2

File f1 is newer than f2.

f1 -ot f2

File f1 is older than f2.

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required