Linux shell comparison operator Description Example file comparison operator-e filename if filename exists, 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, true [-L/usr/bin/grep]-r filename if filename is readable, 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] f Ilename1-nt filename2 if filename1 is newer than filename2, it is true [/tmp/install/etc/services-nt/etc/services] filename1-ot filename2 if filename1 is earlier than filename2, it is a true [/boot/bzImage-ot arch/i386/boot/bzImage] string comparison operator (please note the use of quotation marks, this 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, true [-n "$ myvar"] string1 = string2 if string1 and string2 are the same, true ["$ myvar" = "one two three"] st Ring1! = 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 not equal to [3-ne $ mynum] num1-lt num2 less [3-lt $ mynum] num1-le num2 is less than or equal to [3-le $ mynum] num1-gt num2 is greater than [3-gt $ mynum] num1-ge num2 is greater than or equal [3-ge $ mynum] The test command is used to check whether a condition is true, it can be used to test values, characters, and files. Its Test characters and functions are as follows. (1) numerical test:-eq is equal to true. -If the ne value is not equal to the ne value, it is true. -A value greater than-gt is true. -If ge is greater than or equal to, it is true. -If it is less than, it is true. -If the value of-le is less than or equal to, it is true. (2) string test: = equals to true.! = Not equal to true. The-z string length is false. -If the length of the n string is not pseudo, it is true. (3) file test:-e file name is true if the file exists. -R: The file name is true if the file exists and is readable. -W: The file name is true if the file exists and can be written. -X: the file name is true if the file exists and can be executed. -S file name is true if the file exists and contains at least one character. -The z file name already exists and the length is 0. -D. The file name is true if the file exists and is a directory. -F: The file name is true if the file exists and is a normal file. -C: The file name is true if the file exists and is a special character file. -B: The file name is true if the file exists and is a special file.-o: the file name is true if the file belongs to the user.