Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ test(1) — Ultrix WS 1.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

find(1)

sh(1)

test(1)

NAME

test − test conditional expression

SYNTAX

test expr

DESCRIPTION

The test command evaluates the expression expr, and if its value is true then returns zero exit status; otherwise, a nonzero exit status is returned. test returns a nonzero exit if there are no arguments.

OPTIONS

The following primitives are used to construct expr.

−r file
Tests if the file exists and is readable.

−w file
Tests if the file exists and is writable.

−f file
Tests if the file exists and is not a directory.

−d file
Tests if the file exists and is a directory.

−s file
Tests if the file exists and has a size greater than zero.

−t [ fildes ]
Tests if file descriptor is terminal.  Default is to test descriptor 1.

−z s1
Tests if the length of string s1 is zero. 

−n s1
Tests if the length of the string s1 is nonzero. 

s = s2
Tests if the strings s1 and s2 are equal. 

s1 != s2
Tests if the strings s1 and s2 are not equal. 

s1Tests if s1 is not the null string. 

n1 −eq n2
Tests if number1 equals number2.

n1 −ge n2
Tests if number1 is greater than or equal to number2.

n1 −gt n2
Tests if number1 is greater than number2.

n1 −le n2
Tests if number1 is less than or equal to number2.

n1 −lt n2
Tests if number1 is less than number2.

n1 −ne n2
Tests if number1 does not equal to number2.

These primaries may be combined with the following operators:

!exprNegates evaluation of expression. 

expr −a expr
Tests logical and of two expressions. 

expr −o expr
Tests logical or of two expressions. 

( expr... )
Groups expressions.

The −a has higher precedence than −o.  Notice that all the operators and flags are separate arguments to test. Notice also that parentheses are meaningful to the Shell and must be escaped.

SEE ALSO

find(1), sh(1)

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