TEST(1) BSD Reference Manual TEST(1) NNAAMMEE tteesstt - condition evaluation utility SSYYNNOOPPSSIISS tteesstt _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. --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 _e_x_i_s_t_s _a_n_d _i_s _r_e_a_d_a_b_l_e_. --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 (default 1) 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. _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. _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 the IEEE Std1003.2 (``POSIX''), sec- tion D11.2/4.62.4, standard are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. RREETTUURRNN VVAALLUUEESS 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 function is expected to be IEEE Std1003.2 (``POSIX'') compati- ble. 4.4BSD May 31, 1993 2