AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox AT&T UNIX™PC Unix System V Users Manual - tenox

01.01.2013 Views

I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I

TEST ( 1 ) TEST (I) NAME test - condition evaluation command SYNOPSIS test expr [ expr ] DESCRIPTION Test evaluates the expression expr and, if its value is true, returns a zero (true) exit status; otherwise, a non-zero (false) exit status is returned; test also returns a non-zero exit status if there are no arguments. The following primitives are used to construct expr: -r file true if file exists and is readable. -w file -x file -f file -d file -c file -b file -p file -u file -g file -k file -s file -t [ fildes ] -z sl -n sl sl = s2 sl != s2 sl nl -eq n2 true if file exists and is writable. true if file exists and is executable. true if file exists and is a regular file. true if file exists and is a directory. true if file exists and is a character special file. true if file exists and is a block special file. true if file exists and is a named pipe (fifo). true if file exists and its set-user-ID bit is set. true if file exists and its set-group-ID bit is set. true if file exists and its sticky bit is set. true if file exists and has a size greater than zero. true if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device. true if the length of string sl is zero. true if the length of the string sl is non-zero. true if strings sl and s2 are identical. true if strings sl and s2 are not identical. true if sl is not the null string. true if the integers nl and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -It, and -le may be used in place of -eq. These primaries may be combined with the following operators: unary negation operator. binary and operator. -0 binary or operator ( -a. has higher precedence than -a. - 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. - 1 -

TEST ( 1 ) TEST (I)<br />

NAME<br />

test - condition evaluation command<br />

SYNOPSIS<br />

test expr<br />

[ expr ]<br />

DESCRIPTION<br />

Test evaluates the expression expr and, if its value is true, returns<br />

a zero (true) exit status; otherwise, a non-zero (false) exit status is<br />

returned; test also returns a non-zero exit status if there are no<br />

arguments. The following primitives are used to construct expr:<br />

-r file true if file exists and is readable.<br />

-w file<br />

-x file<br />

-f file<br />

-d file<br />

-c file<br />

-b file<br />

-p file<br />

-u file<br />

-g file<br />

-k file<br />

-s file<br />

-t [ fildes ]<br />

-z sl<br />

-n sl<br />

sl = s2<br />

sl != s2<br />

sl<br />

nl -eq n2<br />

true if file exists and is writable.<br />

true if file exists and is executable.<br />

true if file exists and is a regular file.<br />

true if file exists and is a directory.<br />

true if file exists and is a character special file.<br />

true if file exists and is a block special file.<br />

true if file exists and is a named pipe (fifo).<br />

true if file exists and its set-user-ID bit is set.<br />

true if file exists and its set-group-ID bit is set.<br />

true if file exists and its sticky bit is set.<br />

true if file exists and has a size greater than zero.<br />

true if the open file whose file descriptor number is<br />

fildes (1 by default) is associated with a terminal<br />

device.<br />

true if the length of string sl is zero.<br />

true if the length of the string sl is non-zero.<br />

true if strings sl and s2 are identical.<br />

true if strings sl and s2 are not identical.<br />

true if sl is not the null string.<br />

true if the integers nl and n2 are algebraically<br />

equal. Any of the comparisons -ne, -gt, -ge, -It,<br />

and -le may be used in place of -eq.<br />

These primaries may be combined with the following operators:<br />

unary negation operator.<br />

binary and operator.<br />

-0 binary or operator ( -a. has higher precedence than<br />

-a.<br />

- o).<br />

( expr ) parentheses for grouping.<br />

Notice that all the operators and flags are separate arguments to<br />

test. Notice also that parentheses are meaningful to the shell and,<br />

therefore, must be escaped.<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!