|
Linux BASH syntax : Conditional expressions
Conditional expressions are used by bracketed expressions
and the test
builtin.
Conditional expressions are often used to examine the status of a file.
-a file
-b file
-c file
-d file
-e file
-f file
-g file
-h file
-k file
-p file
-r file
-s file
-t fd
-u file
-w file
-x file
-O file
-G file
-L file
-S file
-N file
file1 -nt file2
file1 -ot file2
file1 -ef file2
-o optname
set
.
-z string
-n string
string
string1 == string2
string1 != string2
string1 < string2
string1 > string2
arg1 OP arg2
OP
is one of `-eq', `-ne',
`-lt', `-le', `-gt', or `-ge'.
These arithmetic binary operators return true if arg1 is equal
to, not equal to, less than, less than or equal to, greater than, or greater
than or equal to arg2, respectively. Arg1 and arg2
may be positive or negative integers. If the file argument to one of the primaries is one of
`/dev/stdin'
`/dev/stdout'
`/dev/stderr'
file descriptor 0, 1, or 2, respectively, is checked.
If the file argument to one of the primaries is of the form `/dev/fd/N',
then file descriptor N is checked.
Related commands:
BASH Syntax
Windows equivalent commands:
IF EXISTS - Conditionally perform a command
Conditionals
- IF THEN ELSE Execution