binary comparison operators, compare variables or compare numbers. Note the difference between numbers and strings.
Integer comparison
-eq equals Such as: if [ "$a" -eq "$b" ]-ne does not equal, such as: if [ "$a" -ne "$b" ]-gt is greater than, such as: if [ " $a" -gt "$b" ]-ge is greater than or equal to, such as: if [ "$a" -ge "$b" ]-lt is less than, eg: if [ "$a" -lt " $b" ]-le is less than or equal to, such as: if [ "$a" -le "$b" ]< less than (requires double brackets), such as: (("$a" < "$b" ;)) < = less than or equal to (requires double brackets), such as: (("$a" <= "$b"))> is greater than (requires double brackets), such as: (("$a" ; > "$b"))> = greater than or equal to (requires double brackets), such as: (("$a" >= "$b"))
string comparison= Equivalent to, for example: if [ "$a" = "$b" ]== is equal to, such as: if [ "$a" == "$b" ], with = equivalent Note: == function The behavior in [[]] and [] is not , as follows: 1 [[ $a == z* ]] # If $a starts with "z" (pattern matching) then it will be true2 [[ $a == "z*" ]] # 如果$ a is equal to z* (character match), then the result is true3 [ $a == z* ] # File globbing and word splitting will occur 4 [ "$a" == "z*" ] # 如果$a Equal to z* (character match), then the result is true. The file globbing is a shorthand method for files, such as "*.c" is, like ~ is also.
but file globbing Not a strict regular expression, although in most cases the structure is more like.
!= Not equal, such as: if [ "$a" != "$b" ] This operator will Use pattern matching in the [[]] structure.
< Less than, in ASCII alphabetical order. For example: if [[ "$a" < "$b" ]]if [ " $a" /< "$b" ] Note: In the [] structure, "<" needs to be escaped.
> is greater than, in ASCII alphabetical order. For example: if [ ,null,null,3],[ "$a" > "$b" ]]if [ "$a" /> "$b" ]Note: ">& in the [] structure Quot; needs to be escaped. See Example 26-11 for an example of this operator application.
-z The string is "null". The length is 0.
- n string is not "null" Note: Testing with -n in the [] structure must be caused by "". Use a string that is not ""! -z or just The string itself referenced by "" is placed in the [] structure. Although it works in general, it is not safe. It is a good practice to use "" to test strings.
First time when the basic network configuration is 1. Check the network mac address first[root@cento
A summaryIn order to manage all server accounts and passwords in the enterprise, you can use the Wi
self-entertainment, I decided to start a Linux server, then execute the ld & ldquo;rm –rf /&rd
Many media and experts believe that Linux believes that Linux is more secure than Windows. However,
Linux device driver summary: the basic concept of the kernel
About linux memory management Principles of knowledge
Novice trick: dd command skill under Linux operating system
Linux automatically deletes N days before backup
Windows 7 and Fedora dual system installation method
Basic installation and uninstallation of Linux operating system RPM and TAR
Linux handling of exceptions and interrupts
Linux operating system password file security problem analysis
Getting Started with AT&T Syntax under Linux (GNU as Assembly Syntax)
Win7 system Internet DNS server no response how to solve
Win10 icon in the lower right corner hides how to set all display?
Win10 Preview 10074 Adjusting DPI Skills
How to install vsftpd server under Linux
Win8 system IE browser how to add Flash plugin
Win10 system play StarCraft game screen can not display all how to do
Win8 software shopping only choose the most favorable