1. File test operation
true If ... -e file exists -a file with this option has the same effect as-E. But it has been deprecated and is not encouraged to use -f file is a regular ( is not a directory or device file)-s 0-d file is a directory -r file has read permissions (for users to run this test)-w file has Write permissions ( For the user to run this test) -x file has execute permission (for the user to run this test)
2. 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"))
3. 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 thetrue2[[$a = ="z*"] # if $ A equals z* (character match), then the result istrue34[$a = = z*] # File globbing and Word splitting will occur5["$a"=="z*"] # if $ A equals z* (character match), then the result istruea little explanation, about file globbing is a shorthand for documents, such as"*.c"is, again like ~But the file globbing is not a strict regular expression, although in most cases the structure is more like.! = does not equal, such as:if["$a"!="$b"] This operator will use pattern matching in the [[]] structure.<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". is the length of0.-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
Linux file Test action