Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ test(1) — A/UX 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

find(1)

ksh(1)

sh(1)




test(1) test(1)
NAME test - condition evaluation command SYNOPSIS test [expr] DESCRIPTION test evaluates the expression expr and, if its value is true, returns a zero (true) exit status; otherwise, a nonzero (false) exit status is returned. test also returns a nonzero exit status if there are no arguments. The su- peruser is always granted execute permission even though ex- ecute permission is meaningful only for directories and reg- ular files and exec requires that at least one execute mode bit be set for a regular file to be executable. The follow- ing primitives are used to construct expr. -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 device file. -b file True if file exists and is a block device file. -p file True if file exists and is a named pipe (FIFO). -u file True if file exists and its set-user-ID bit is set. -g file True if file exists and its set-group-ID bit is set. -k file True if file exists and its sticky bit is set. -s file True if file exists and has a size greater than zero. -t [fildes] True if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device. -z s1 True if the length of string s1 is zero. -n s1 True if the length of string s1 is nonzero. April, 1990 1



test(1) test(1)
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 algebraical- ly equal. Any of the comparisons -ne, -gt, -ge, -lt, and -le may be used in place of -eq. These primaries may be combined with the following opera- tors: ! Unary negation operator. -a Binary AND operator. -o Binary OR operator (-a has higher precedence than -o). (expr) Parentheses for grouping. Notice that all the operators and flags are separate argu- ments to test. Notice also that parentheses are meaningful to the shell and, therefore, must be escaped. EXAMPLES test is typically used in shell scripts (sh(1)), as in the following example, which prints the message ``foo is a directory'' if it is found to be one when test is run. if test -d foo then echo "foo is a directory" fi SEE ALSO find(1), ksh(1), sh(1). ``Bourne Shell Reference'' and ``Korn Shell Reference'' in A/UX User Interface. 2 April, 1990

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026