|
test — check file types and compare values
test
EXPRESSION
test
[
expression ]
[
]
[
OPTION
Exit with the status determined by EXPRESSION.
−−help
display this help and exit
−−version
output version information and exit
An omitted EXPRESSION defaults to false. Otherwise, EXPRESSION is true or false and sets exit status. It is one of:
EXPRESSION is true
EXPRESSION is false
−a
EXPRESSION2both EXPRESSION1 and EXPRESSION2 are true
−o
EXPRESSION2either EXPRESSION1 or EXPRESSION2 is true
−n
STRINGthe length of STRING is nonzero
STRING
equivalent to −n
STRING
−z
STRINGthe length of STRING is zero
the strings are equal
the strings are not equal
−eq
INTEGER2INTEGER1 is equal to INTEGER2
−ge
INTEGER2INTEGER1 is greater than or equal to INTEGER2
−gt
INTEGER2INTEGER1 is greater than INTEGER2
−le
INTEGER2INTEGER1 is less than or equal to INTEGER2
−lt
INTEGER2INTEGER1 is less than INTEGER2
−ne
INTEGER2INTEGER1 is not equal to INTEGER2
−ef
FILE2FILE1 and FILE2 have the same device and inode numbers
−nt
FILE2FILE1 is newer (modification date) than FILE2
−ot
FILE2FILE1 is older than FILE2
−b
FILEFILE exists and is block special
−c
FILEFILE exists and is character special
−d
FILEFILE exists and is a directory
−e
FILEFILE exists
−f
FILEFILE exists and is a regular file
−g
FILEFILE exists and is set−group−ID
−G
FILEFILE exists and is owned by the effective group ID
−h
FILEFILE exists and is a symbolic link (same as
−L
)
−k
FILEFILE exists and has its sticky bit set
−L
FILEFILE exists and is a symbolic link (same as
−h
)
−O
FILEFILE exists and is owned by the effective user ID
−p
FILEFILE exists and is a named pipe
−r
FILEFILE exists and read permission is granted
−s
FILEFILE exists and has a size greater than zero
−S
FILEFILE exists and is a socket
−t
FDfile descriptor FD is opened on a terminal
−u
FILEFILE exists and its set−user−ID bit is set
−w
FILEFILE exists and write permission is granted
−x
FILEFILE exists and execute (or search) permission is granted
Except for −h
and
−L
, all FILE−related
tests dereference symbolic links. Beware that parentheses
need to be escaped (e.g., by backslashes) for shells. INTEGER
may also be −l
STRING,
which evaluates to the length of STRING.
Note | |
---|---|
[ honors the |
Note | |
---|---|
Your shell may have its own version of test and/or [, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. |
Report test bugs to bug−coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report test translation bugs to <http://translationproject.org/team/>
The full documentation for test is maintained as a Texinfo manual. If the info and test programs are properly installed at your site, the command
info coreutils 'test invocation'
should give you access to the complete manual.
COPYRIGHT |
---|
Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. |