The [[...]] command is used to evaluate conditional expressions with file attributes, strings, and integers. The basic format is:
[[expression]]
where expression is the condition you are evaluating. There must be whitespace after the opening brackets, and before the closing brackets. Whitespace must also separate the expression arguments and operators. If the expression evaluates to true, then a zero exit status is returned, otherwise the expression evaluates to false and a non-zero exit status is returned.
–n string | true if length of string is not zero |
–o option | true if option is set |
–z string | true if length of string is zero |
string1 = string2 | true if string1 is equal to string2 |
string1 != string2 | true if string1 is not equal to string2 |
string = pattern | true if string matches pattern |
string != pattern | true if string does not match pattern |
string1 < string2 | true if string1 is less than string2 |
string1 > string2 | true if string1 is greater than string2 |
–a file | true if file exists |
–b file | true if file exists and is a block special file |
–c file | true if file exists and is a character special file |
–d file | true if file exists and is a directory |
–f file | true if file exists is a regular file |
–g file | true if file exists and its setgid bit is set |
–G file | true if file exists and its group id matches the current effective group id |
–k file | true if file exists and its sticky bit is set |
–L file | true if file exists and is a symbolic link |
–O file | true if file exists and is owned by the effective user id |
–p file | true if file exists and is a fifo special file or a pipe |
–r file | true if file exists and is readable |
–s file | true if file exists and its size is greater than zero |
–S file | true if file exists and is a socket |
–t n | true if file descriptor n is open and associated with a terminal device |
–u file | true if file exists and its set user-id bit is set |
–w file | true if file exists and is writable |
–x file | true if file exists and is executable. If file is a directory, then true indicates that the directory is readable. |
file1 –ef file2 | true if file1 and file2 exist and refer to same file |
file1 –nt file2 | true if file1 exists and is newer than file2 |
file1 –ot file2 | true if file1 exists and is older than file2 |
exp1 –eq exp2 | true if exp1 is equal to exp2 |
exp1 –ne exp2 | true if exp1 is not equal to exp2 |
exp1 –le exp2 | true if exp1 is less than or equal to exp2 |
exp1 –lt exp2 | true if exp1 is less than exp2 |
exp1 –ge exp2 | true if exp1 is greater than or equal to exp2 |
exp1 –gt exp2 | true if exp1 is greater than exp2 |
3.145.191.134