Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ test(1) — A/UX 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

find(1)

ksh(1)

sh(1)




test(1) test(1)
NAME test - evaluates conditions SYNOPSIS test [expr] ARGUMENTS expr Specifies the expression to be evaluated by the test command. 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. The test command also returns a nonzero exit status if there are no arguments. The superuser is always granted execute permission even though execute permission is meaningful only for directories and regular files and exec requires that at least one execute mode bit be set for a regular file to be executable. The following 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. January 1992 1



test(1) test(1)
-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. 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 algebraically 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 operators: ! 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 arguments to test. Notice also that parentheses are meaningful to the shell and, therefore, must be escaped. EXAMPLES The test command is typically used in shell scripts (sh(1)), as follows: if test -d foo then 2 January 1992



test(1) test(1)
echo "foo is a directory" fi The following message: foo is a directory will print if it is found to be one when test is run. FILES /bin/test Executable file SEE ALSO find(1), ksh(1), sh(1) ``Bourne Shell Reference'' in A/UX Shells and Shell Programming ``Korn Shell Reference'' in A/UX Shells and Shell Programming January 1992 3

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