integer comparison-eq equals, as:if["$a"-eq"$b" ]-ne not equal to, such as:if["$a"-ne"$b" ]-GT greater than, as:if["$a"-gt"$b" ]-ge is greater than or equal to, such as:if["$a"-ge"$b" ]-lt less than, such as:if["$a"-lt"$b" ]-le less than equals, such as:if["$a"-le"$b" ]< less (requires double brackets), such as: (("$a"<"$b"))<= is less than or equal (requires double brackets), such as: (("$a"<="$b"))> is greater than (requires double brackets), such as: (("$a">"$b"))>= is greater than or equal to (requires double brackets), such as: (("$a">="$b") ) string comparison= Equals, as:if["$a"="$b" ]= = equals, as:if["$a"=="$b"], and =Equivalence Note:==the functions in [[]] and [] are different, as follows:1[[$a = = z*]] # if $ A"Z"Start (Pattern match) then true2[[$a = ="z*"] # if $ A equals z*(character match), then the result is true34[$a = = z*] # File globbing and Word splitting will occur5["$a"=="z*"] # if $ A equals z*(character match), then the result is true to explain that file globbing is a shorthand for files, such as"*.c"is, again like ~but, too.fileglobbing is not a strict regular expression, although in most cases the structure is more like.! = does not equal, such as:if["$a"!="$b" ]<less than, in ASCII alphabetical order. such as:if[["$a"<"$b" ]]if["$a"\<"$b"] Note: In the [] structure"<"need to be escaped.>greater than, in ASCII alphabetical order. such as:if[["$a">"$b" ]]if["$a"\>"$b"] Note: In the [] structure">"need to be escaped. Specific reference Example -- Oneto see an example of this operator application.-Z string is"NULL". That is, the length is 0.-N String not for"NULL"Note: Use-N test in [] structure must be used""The variable. Use a non-""The string to use! -Z or just not used""The referenced string itself, placed in the [] structure (see example7-6Although it is generally possible to work, it is unsafe. Accustomed to use""It's a good habit to test strings. [1]
Linux Shell Learning notes-compare operations