TEST(1)                 NetBSD General Commands Manual                 TEST(1)

NNAAMMEE
    tteesstt, [[ - condition evaluation utility

SSYYNNOOPPSSIISS
    tteesstt _e_x_p_r_e_s_s_i_o_n
    [[ _e_x_p_r_e_s_s_i_o_n ]

DDEESSCCRRIIPPTTIIOONN
    The tteesstt utility evaluates the expression and, if it evaluates to true,
    returns a zero (true) exit status; otherwise it returns 1 (false).  If
    there is no expression, test also returns 1 (false).

    All operators and flags are separate arguments to the tteesstt utility.

    The following primaries are used to construct expression:

    --bb _f_i_l_e       True if _f_i_l_e exists and is a block special file.

    --cc _f_i_l_e       True if _f_i_l_e exists and is a character special file.

    --dd _f_i_l_e       True if _f_i_l_e exists and is a directory.

    --ee _f_i_l_e       True if _f_i_l_e exists (regardless of type).

    --ff _f_i_l_e       True if _f_i_l_e exists and is a regular file.

    --gg _f_i_l_e       True if _f_i_l_e exists and its set group ID flag is set.

    --hh _f_i_l_e       True if _f_i_l_e exists and is a symbolic link.

    --kk _f_i_l_e       True if _f_i_l_e exists and its sticky bit is set.

    --nn _s_t_r_i_n_g     True if the length of _s_t_r_i_n_g is nonzero.

    --pp _f_i_l_e       True if _f_i_l_e is a named pipe (FIFO).

    --rr _f_i_l_e       True if _f_i_l_e exists and is readable.

    --ss _f_i_l_e       True if _f_i_l_e exists and has a size greater than zero.

    --tt _f_i_l_e___d_e_s_c_r_i_p_t_o_r
                  True if the file whose file descriptor number is
                  _f_i_l_e___d_e_s_c_r_i_p_t_o_r is open and is associated with a terminal.

    --uu _f_i_l_e       True if _f_i_l_e exists and its set user ID flag is set.

    --ww _f_i_l_e       True if _f_i_l_e exists and is writable.  True indicates only
                  that the write flag is on.  The file is not writable on a
                  read-only file system even if this test indicates true.

    --xx _f_i_l_e       True if _f_i_l_e exists and is executable.  True indicates only
                  that the execute flag is on.  If _f_i_l_e is a directory, true
                  indicates that _f_i_l_e can be searched.

    --zz _s_t_r_i_n_g     True if the length of _s_t_r_i_n_g is zero.

    --LL _f_i_l_e       True if _f_i_l_e exists and is a symbolic link.  This operator
                  is retained for compatibility with previous versions of
                  this program.  Do not rely on its existence; use --hh
                  instead.

    --OO _f_i_l_e       True if _f_i_l_e exists and its owner matches the effective
                  user id of this process.

    --GG _f_i_l_e       True if _f_i_l_e exists and its group matches the effective
                  group id of this process.

    --SS _f_i_l_e       True if _f_i_l_e exists and is a socket.

    _f_i_l_e_1 --nntt _f_i_l_e_2
                  True if _f_i_l_e_1 exists and is newer than _f_i_l_e_2.

    _f_i_l_e_1 --oott _f_i_l_e_2
                  True if _f_i_l_e_1 exists and is older than _f_i_l_e_2.

    _f_i_l_e_1 --eeff _f_i_l_e_2
                  True if _f_i_l_e_1 and _f_i_l_e_2 exist and refer to the same file.

    _s_t_r_i_n_g        True if _s_t_r_i_n_g is not the null string.

    _s_1 == _s_2       True if the strings _s_1 and _s_2 are identical.

    _s_1 !!== _s_2      True if the strings _s_1 and _s_2 are not identical.

    _s_1 << _s_2       True if string _s_1 comes before _s_2 based on the ASCII value
                  of their characters.

    _s_1 >> _s_2       True if string _s_1 comes after _s_2 based on the ASCII value
                  of their characters.

    _n_1 --eeqq _n_2     True if the integers _n_1 and _n_2 are algebraically equal.

    _n_1 --nnee _n_2     True if the integers _n_1 and _n_2 are not algebraically equal.

    _n_1 --ggtt _n_2     True if the integer _n_1 is algebraically greater than the
                  integer _n_2.

    _n_1 --ggee _n_2     True if the integer _n_1 is algebraically greater than or
                  equal to the integer _n_2.

    _n_1 --lltt _n_2     True if the integer _n_1 is algebraically less than the inte-
                  ger _n_2.

    _n_1 --llee _n_2     True if the integer _n_1 is algebraically less than or equal
                  to the integer _n_2.

    These primaries can be combined with the following operators:

    !! _e_x_p_r_e_s_s_i_o_n  True if _e_x_p_r_e_s_s_i_o_n is false.

    _e_x_p_r_e_s_s_i_o_n_1 --aa _e_x_p_r_e_s_s_i_o_n_2
                  True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true.

    _e_x_p_r_e_s_s_i_o_n_1 --oo _e_x_p_r_e_s_s_i_o_n_2
                  True if either _e_x_p_r_e_s_s_i_o_n_1 or _e_x_p_r_e_s_s_i_o_n_2 are true.

    ((_e_x_p_r_e_s_s_i_o_n))  True if expression is true.

    The --aa operator has higher precedence than the --oo operator.

GGRRAAMMMMAARR AAMMBBIIGGUUIITTYY
    The tteesstt grammar is inherently ambiguous.  In order to assure a degree of
    consistency, the cases described in IEEE Std 1003.2 (``POSIX.2'') section
    4.62.4, are evaluated consistently according to the rules specified in
    the standards document.  All other cases are subject to the ambiguity in
    the command semantics.

EEXXIITT SSTTAATTUUSS
    The tteesstt utility exits with one of the following values:

    0       expression evaluated to true.

    1       expression evaluated to false or expression was missing.

    >1      An error occurred.

SSTTAANNDDAARRDDSS
    The tteesstt utility implements a superset of the IEEE Std 1003.2
    (``POSIX.2'') specification.

NetBSD 2.1                       May 31, 1993                       NetBSD 2.1