After a netizen watched the old boy's shell video today, he asked the following question:
650) This. width = 650; "Title =" snap17.jpg "alt =" wkiol1oz8i_gwllfaaetvavr46c745.jpg "src =" http://s3.51cto.com/wyfs02/M00/38/8A/wKioL1Oz8i_gWlLFAAEtVAvr46c745.jpg "/>
Solution:
The best way to learn shell is to refer to the benchmark script of the system and example of help.
The following is an example of the nic startup script for this user.
650) This. width = 650; "style =" float: none; "Title =" image003.png "alt =" wkiol1oz8emwtevkaac7nd7sblc481.jpg "src =" http://s3.51cto.com/wyfs02/M01/38/8A/wKioL1Oz8emwtevkAAC7Nd7SBlc481.jpg "/>
Obviously, the above-mentioned brackets compare the equal signs with spaces on both sides. Therefore, the answer to the above questions is self-evident.
[[email protected] ~]# cat oldboytest.sh #!/bin/shstra=‘aa‘strb=‘bb‘ if [ "$stra" == "aa" -a "$strb" == "bb" ];then echo "true"else echo "false"fi if [[ "$stra" == "aa" && "$strb" == "cc" ]];then echo "true"else echo "false"fi[[email protected] ~]# sh oldboytest.sh truefalse
Pay attention to details: especially spaces that are easy to ignore, which is critical in shell.
This article from the "old boy Linux O & M" blog, please be sure to keep this source http://oldboy.blog.51cto.com/2561410/1433688