File comparison operator, comparison operator
File comparison operator
-E filename if filename exists, it is true [-e/var/log/syslog]
-D filename if filename is a directory, it is true [-d/tmp/mydir]
-F filename if filename is a regular file, it is true [-f/usr/bin/grep]
-L filename if filename is a symbolic link, it is true [-L/usr/bin/grep]
-R filename if filename is readable, it is true [-r/var/log/syslog]
-W filename if filename is writable, it is true [-w/var/mytmp.txt]
-X filename if filename is executable, it is true [-L/usr/bin/grep]
Filename1-nt filename2 if filename1 is newer than filename2, true [/tmp/install/etc/services-nt/etc/services]
Filename1-ot filename2 if filename1 is older than filename2, true [/boot/bzImage-ot arch/i386/boot/bzImage]
String comparison operator (please note the use of quotation marks, which is a good way to prevent space from disturbing the code)
-Z string if the string length is zero, it is true [-z "$ myvar"]
-N string if the string length is not zero, it is true [-n "$ myvar"]
String1 = string2 if string1 is the same as string2, it is true ["$ myvar" = "one two three"]
String1! = String2 if string1 is different from string2, it is true ["$ myvar "! = "One two three"]
Arithmetic comparison operator
Num1-eq num2 equals to [3-eq $ mynum]
Num1-ne num2 is not equal to [3-ne $ mynum]
Num1-lt num2 less than [3-lt $ mynum]
The num1-le num2 is less than or equal to [3-le $ mynum]
Num1-gt num2 greater than [3-gt $ mynum]
Num1-ge num2 is greater than or equal to [3-ge $ mynum]
PS (reproduced): http://zhidao.baidu.com/link? Url = qxbyyzZeyrF-hPVn2OGrFRsUTXp1XERdFCLJAnC6UkDjpb_vTdnWhgC8CiQTzS8K1hbtOjJQEZ9XZobQl74Wxq