grammar
[Analyzing Expression]
Folder or path exists
- -e target is present (exist)
- -d whether the path (directory)
- Whether -f file (file)
[-E text. SH ] || Touch text. SH # text.sh does not exist to create
The existence of rights
- Are -r has read access (read)
- Whether -w have write access (write)
- Are -x Executive authority (excute)
[Named text.txt in the -X-] && echo ' Executive authority ' # determines whether permission to execute
Integer comparison size (only for comparison integer)
-
-
-ne not equal (not equal)
-
-gt greater than (greater than)
-
-lt less than (lesser than)
-
-ge greater than or equal to (greater or equal)
-
-le less than or equal to (lesser or equal)
[ . 9 -gt . 8 ] && echo ' greater than '
Compare the size of the float (With bc)
- Comparison of the size bc, true: 1 false: 0
` Echo ' 1.2 <1.3 ' | bc` # bc size comparison using [` echo ' 1.2 <1.3 ' | bc` -eq 1 ] # 1 and then compared. The results can be derived
String comparison
-
-
= Equivalent to == Equal to different only in [[]] and the performance in []
-
! = Not equal
[ ' Kkkkk ' ! = ' Kkkk ' ] && echo ' not equal '
Multi-conditional
# [[]] && and || only with the use of [[ " A " = " A " && " B " = " B " ]] # [] which can only fit -a -o or use, with the outside to && || or using [ " A " = " A " -a " B " = " B " ] [ " A " = " A " -o " B " = "b" ] [ "a" = "a"] && [ "b" = "b" ]