Test Unix

Test Unix

test (Unix)
From Wikipedia, the free encyclopedia
This article may need to be rewritten entirely to comply with Wikipedia's quality standards. You can help. The discussion page may contain suggestions. (May 2009)
test is a command-line utility found in Unix-like operating systems that evaluates conditional expressions.

test expression

[ expression ]
The test command in Unix evaluates the expression parameter. In some shells (such as FreeBSD sh(1)), it is a shell builtin, even though external version may still exists. In the second form of the command, the [ ] (brackets) must be surrounded by blank spaces, this is because the /bin/ directory [ is a program and POSIX compatible shells require a space between the program name and its arguments. One must test explicitly for file names in the C shell. File-name substitution (globbing) causes the shell script to exit.

The following functions are used to construct this parameter:

-e FileName - FileName exists.
Note: All remaining functions return true if the object (file or string) exists, and the condition specified is true.

-b Filename - Returns a True exit value if the specified FileName exists
and is a block special file.
-c FileName - FileName is a character special file.
-d FileName - FileName is a directory.

-f FileName - FileName is a regular file.
-g FileName - FileName's Set Group ID bit is set.
-h FileName - FileName is a symbolic link.
-k FileName - FileName's sticky bit is set.
-L FileName - FileName is a symbolic link.
-p FileName - FileName is a named pipe (FIFO).
-r FileName - FileName is readable by the current process.
-s FileName - FileName has a size greater than 0.
-t FileDescriptor - FileDescriptor is open and associated with a terminal.
-u FileName - FileName's Set User ID bit is set.
-w FileName - FileName's write flag is on. However, the FileName will
not be writable on a read-only file system even if test indicates...

Similar Essays