1、太复杂了,记不住的,有没有什么规则呀?
The == comparison operator behaves differently within a double-brackets test than within single brackets.
|
2、测试数值用[ "$a" -ne "$b" ],测试字符串用[ "$a" != "$b" ]。
3、Example 7-6. Testing whether a string is null通过几个例子反复说:测试字符串一定要用双引号把字符串变量括起来!从前面看,测试数值变量同样是把变量用双引号括起来的,这样,可以总结说,无论是数值变量和字符串变量都必须加双引号。
4、Example 7-7. zmore中测试文件类型的语句,不懂
|
5、复合比较:
1)、[[ condition1 && condition2 ]]相当于 [ "$exp1" -a "$exp2" ]
2)、在比较空字符串时,应该在有可能是空字符串的字符串前加上额外的字符,文中说:
|
英语疑问:
1、globbing
File globbing and word splitting take place.
2、Caution advised, however.
10 # Bash permits integer operations and comparisons on variables
11 #+ whose value consists of all-integer characters.
12 # Caution advised, however.
3、sealing wax, cabbages and kings
2 # str-test.sh: Testing null strings and unquoted strings,
3 #+ but not strings and sealing wax, not to mention cabbages and kings . . .
4、compound comparison
5、suffice:
As S.C. points out, in a compound test, even quoting the string variable
might not suffice.
6、the "x's" cancel out(上面5的2))