TEST(1)

NAME
test - test a logical condition

SYNOPSIS
test expression [ ] ]

DESCRIPTION
The test program tests a logical condition. If that condition is true, it exits with a value of EXIT_SUCCESS, and with EXIT_FAILURE if the condition is false. In case of an argument error (such as malformed expressions), the program returns the exit status 2. An optional ] at the end of the expression is swallowed. This makes it easy to install test with a link from [, so that certain incompatibly written shell files work. A number in the following description is a string of digits, optionally prefixed by a minus sign (a plus sign is not allowed). The character string is interpreted as a decimal, signed integer, and internally has the type int. If the string overflows the range for signed integers, an error occurs. test understands the following expressions:

str1
    True if str1 and str2 are nonempty equal strings

str1
    True if str1 and str2 are nonempty unequal strings

str1
    True if str1 and str2 are both nonempty strings, and if both are either equal, or if str1 comes lexicographically after str2 in the machine's native character set ordering

str1
    True if str1 and str2 are both nonempty strings, and if str1 comes lexicographically after str2 in the machine's native character set ordering

str1
    True if str1 and str2 are both nonempty strings, and if both are either equal, or if str1 comes lexicographically beg#fore str2 in the machine's native character set ordering

str1
    True if str1 and str2 are both nonempty strings, and if str1 comes lexicographically before str2 in the machine's native character set ordering

num1
    True if num1 and num2 are both numbers and are equal

num1
    True if num1 and num2 are both numbers and are unequal

num1
    True if num1 and num2 are both numbers and if num1 is greater than or equal to num2

num1
    True if num1 and num2 are both numbers, and if num1 is strictly greater than num2

num1
    True if num1 and num2 are both numbers and if num1 is less than or equal to num2

num1
    True if num1 and num2 are both numbers, and if num1 is strictly less than num2

-e  True if file exists

-f  True if file exists and is a regular file

-d  True if file exists and is a directory

-b  True if file exists and is a block special file

-c  True if file exists and is a character special file

-l  True if file exists and is a symbolic link

-F  True if file exists and is a fifo

-r  True if file exists and is readable by the caller

-w  True if file exists and is writable by the caller

-x  True if file exists and is executable by the caller

FILES
The file

COPYING
    Tells the copying conditions for this program.

BUGS
For the moment, there is no way to make better string comparisons, for example, by looking at the locale, or offering options to compare strings as case-insensitive etc.

Please mail bug reports to neuhaus@informatik.uni-kl.de, or write to me at Stephan Neuhaus, Hilgardring 32, D-6750 Kaiserslautern, Germany.

AUTHOR
test was written by Stephan Neuhaus (neuhaus@informatik.uni-kl.de), and last modified on 2 May, 1992.

COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (contained in the file COPYING) for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.