There are three types of conditions that are commonly tested in bash
Conditional test expression: [expression] [[expression]]
First: Integer test:
-eq tests whether two integers are equal, such as [$A-eq $B]
-ne test two integers in different sizes
-GT Test if one number is greater than the other (great than)
-LT Test if one number is less than the other (lesser than)
-ge greater than or equal to
-le less than or equal to
-ne Not equal to
The second type: file test:
-e file name or file path test file exists Eg:[-e/etc/inittab] if[!-e $FILE]
-F file name or file path test file is normal file
-d file name or file path test file is directory
-R-W-X tests whether the current user has read and write execution permissions on the specified file Eg:[-x/etc/rc.d/rc.sysinit]
The third type: string test:
= = is used to test for equality of strings. If you use =, you have a space at both ends.
! = tests whether to vary
>
<
-N String: Tests whether the specified string is empty, empty is true, and not empty is false.
-Z String: Tests whether the specified string is not empty, is true, empty is false
Linux shell Programming (ii) Condition testing