TEST(1)

NAME
test - evaluate expression

SYNOPSIS
test expression

DESCRIPTION
test returns the status of the expression.

OPTIONS

! expression
    invert expression.

(-e | -s) file
    file exists and has (any size [-e] | non-zero size [-s]).

(-f | -d | -p | -hL | -S | -b | -c) file
    file exists and is a (regular file [-f] | directory [-d] | named pipe [-p] | symbolic link [-h | -L] | socket [-S] | block special [-b] | character special [-c]).

(-k | -g | -u | -r | -w | -x) file
    file exists and has ((sticky) 1 [-k] | setgid(2) [-g] | setuid(4) [-u] | read(4) [-r] | write(2) [-w] | execute(1) [-x]) permissions.

-t fd
    fd as a file descriptor is associated with a terminal.

string
    True if string is not the null string.

(-z | -n) string
    True if string has (zero [-z] | non-zero [-n]) length.

s1 (= | !=) s2
    True if strings s1 and s2 are (identical [=] | different [!=]).

n1 (-eq | -ne | -gt | -ge | -le | -lt) n2
    True if integers n1 and n2 are (= [-eq] | != [-ne] | > [-gt] | >= [-ge] | <= [-le] | < [-lt]).

f1 (-ef | -ot | -nt) f2
    True if file f1 (refer to the same inode as [-ef] | has an older mtime than [-ot] | has a newer mtime than [-nt]) file f2.

EXIT STATUS

0   expression is true.

1   expression is false.

> 1 An error occurred.

SEE ALSO
expr(1)

STANDARDS
POSIX.1-2013.