Echo ' 1.2*2 ' |BC
++++++++++++++++ Digital Comparison
Mode 1:
Agm1=50
Agm2=60
If [3-eq 3-a ${agm1}-ne ${agm2}-a ${agm2}-gt ${agm1}-a ${agm1}-ge 50-a ${agm1}-lt ${agm2}-a ${AGM2}-le 60- o 4-GT 3]; Then
Echo ' Yes '
Else
Echo ' No '
Fi
Mode 2:
Agm1= ' ye '
Agm2= ' ye '
if [["$agm 1" = = "$AGM 2" && "$AGM 1" = = ' ye ' && 2 > 1 && 1 < 2]]; Then
Echo ' Yes '
Else
Echo ' No '
Fi
Note: String comparisons must be double-quoted
Summarize:
-F file is present
Whether the-D directory exists
-s file exists and is not empty
-E exists as a directory or file
-L whether shortcut link
-R file is readable
-W file is writable
-X file is executable
-eq is equal
-ne is not equal to
-ge is greater than or equal to
-GT is greater than
-le is less than or equal to
-lt is less than
-A and
-O or
[*] curly braces General letters available
[[*]] double braces General && | | > < >= <= = = = Match available
The above related can be explained in detail in Help test
Conditional control Statements
Get memory Size: free-m |grep buffers\/|awk ' {print $NF} '
Judge whether the number:
#!/bin/bash
Str= ' 123 '
[-N "' Echo ${str}|sed ' s#[0-9]# #g '"] && {
echo ' no int '
Exit 1
}
Or
[-N ' ' echo hello123|sed ' s/[0-9]//g ' "] && echo ' no int ' | | echo ' is int '
This article from the "Development and operation of the" blog, declined to reprint!
Shell file Number comparison