Bash three test integer file strings (String)
String test
= = Note The test must have a space on both sides of the equal sign, and a space in the brackets to test whether the string is equal, and so is true, not equal to False
! = Test two strings, whether unequal, unequal to true, etc as false
-N string to test whether the specified string is empty, empty is true, and not empty for false
-S string tests whether the specified string is not empty, is not empty, is true, and Null is False
How to use
Cases
[Email protected] script]# A=name
[Email protected] script]# B=unname
[[Email protected] script]# [$A = $B] test two strings for equality note = There are spaces on either side of the number
[[email protected] script]# echo $?
1
[Email protected] script]# [$A! = $B]
[[email protected] script]# echo $?
0
[Email protected] script]#
String test and for loop