Analyzing two shell script symbol []

Analyzing the symbol [] is similar test. [But] there is a wildcard and regular expression, in order to distinguish, use [] to determine when to do, both before and after the need to distinguish between spaces. Another pit

【 -z "$HOME" 】;echo $?

Example:

Read -p. 1 "Please INPUT (Y / n-):" Yn
2 [ "$ Yn" == "the Y" -o "$ Yn" == "Y"] && echo "the OK, Continue" 0 && Exit
. 3 [ "Yn $" == "N" -o "$ Yn" == "n-"] && echo "Oh, interrupt" 0 && Exit
. 4 echo "What I donnot know your Choice IS" 0 && Exit
there are several points. [] Must be spaces. it is necessary. "$ Yn" == "Y" is also necessary to add a space, otherwise it will print OK, continue. That is to say, nothing to add spaces nothing wrong. But do not put spaces of time, do not add a space, the blog post is an example. . . . The pit must be tamped up. Otherwise reason, can not find out where the problem

 

Guess you like

Origin www.cnblogs.com/Lonelychampion/p/11244831.html