File comparison Operators
-e filename true if filename exists [-e/var/log/syslog]
-D filename true If filename is a directory [-d/tmp/mydir]
-F filename true If filename is a regular file [-f/usr/bin/grep]
-L filename true If filename is a symbolic link [-l/usr/bin/grep]
-R filename true if filename is readable [-r/var/log/syslog]
-W filename If filename is writable, true [-w/var/mytmp.txt]
-X filename is true if filename is executable [-l/usr/bin/grep]
Filename1-nt filename2 If filename1 is newer than filename2, then true [/tmp/install/etc/services-nt/etc/services]
Filename1-ot filename2 If filename1 is older than filename2, then true [/boot/bzimage-ot arch/i386/boot/bzimage]
String comparison operators (note the use of quotation marks, which is a good way to prevent whitespace from disturbing the code)
-Z string True if string length is zero [-Z ' $myvar ']
-N String If string length is nonzero, true [-N ' $myvar ']
string1= string2 If string1 is the same as string2, then true ["$myvar" = "One of the three"]
string1!= string2 if string1 differs from string2, true [" $myvar"! = "one, three"]
Arithmetic comparison operators
Num1-eq num2 equals [3-eq $mynum]
Num1-ne num2 Not equal to [3-ne $mynum]
Num1-lt num2 less than [3-lt $mynum]
Num1-le num2 less than or equal to [3-le $mynum]
NUM1-GT num2 Greater than [3-gt $mynum]
Num1-ge num2 greater than or equal to [3-ge $mynum]
This article is from the "Linux" blog, so be sure to keep this source http://study89757.blog.51cto.com/8683527/1726896
File comparison Operators