(coreutils.info)test invocation
16.3 `test': Check file types and compare values
================================================
`test' returns a status of 0 (true) or 1 (false) depending on the
evaluation of the conditional expression EXPR. Each part of the
expression must be a separate argument.
`test' has file status checks, string operators, and numeric
comparison operators.
`test' has an alternate form that uses opening and closing square
brackets instead a leading `test'. For example, instead of `test -d
/', you can write `[ -d / ]'. The square brackets must be separate
arguments; for example, `[-d /]' does not have the desired effect.
Since `test EXPR' and `[ EXPR ]' have the same meaning, only the former
form is discussed below.
Synopses:
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
Due to shell aliases and built-in `test' command, using an unadorned
`test' interactively or in a script may get you different functionality
than that described here. Invoke it via `env' (i.e., `env test ...')
to avoid interference from the shell.
If EXPRESSION is omitted, `test' returns false. If EXPRESSION is a
single argument, `test' returns false if the argument is null and true
otherwise. The argument can be any string, including strings like
`-d', `-1', `--', `--help', and `--version' that most other programs
would treat as options. To get help and version information, invoke
the commands `[ --help' and `[ --version', without the usual closing
brackets. Note: Common options.
Exit status:
0 if the expression is true,
1 if the expression is false,
2 if an error occurred.
File type tests- -[bcdfhLpSt]
Access permission tests- -[gkruwxOG]
File characteristic tests- -e -s -nt -ot -ef
String tests- -z -n = !=
Numeric tests- -eq -ne -lt -le -gt -ge
Connectives for test- ! -a -o
automatically generated by info2www version 1.2.2.9