编程
推荐内容

linuxshell中if的各种判断

作者/整理:admin 来源: 2020-05-08

      -GFILE如其FILE在且属功勋用户组则为真。

      -le小于对等则为真。

      -kFILE如其FILE在且曾经设立了粘制位则为真。

      -gFILE如其FILE在且曾经设立了SGID则为真。

      (2)字串测试:=对等则为真。

      2)bash与ksh中的不一样在redhat9的bash中也得以使用记号。

      -o当由pathname指定的文书或目次在而且被卧眼下过程的功勋用户ID所指定的用户有时归来真。

      -dDIR如其FILE在且是一个目次则为真。

      bash-xtijian.sh60170+weight=60+height=170+idealweight=60+\60-le60\+echoYoushouldeatabitmorefat.Youshouldeatabitmorefat.内中-x用来检讨本子的履行市况if文句格式if环境thenCommandelseCommandfi别忘了这结尾if文句忘了结尾fitest.sh:line14:syntaxerror:unexpectedendoffiif的三种环境抒发式ifcommandthenif因变量then下令履行胜利,对等归来0(例如grep,找到配合)履行挫折,归来非0(grep,没找到配合)ifexpression_r_r_rthen抒发式后果为真,则归来0,if把0值引向theniftestexpression_r_r_rthen抒发式后果为假,则归来非0,if把非0值引向then&&——快捷if-f"/etc/shadow"&&echo"Thiscomputerusesshadowpasswors"&&得以了解为then如其左首的抒发式为真则履行右首的文句shell的if与c言语if的作用上的区分shellifc言语if0为真,走then正好反而,非0走then不撑持平头变量径直if务须:ifi–ne0但是撑持字符串变量径直ififstr如其字符串非0撑持变量径直ifif(i)以command当做if环境以多条command或因变量当做if环境echo–ninput:readuserif多条训令,这些下令之间一定于and(与)grep$user/etc/passwd>/tmp/nullwho-u|grep$userthen上头的训令都履行胜利,归来值$?为0,0为真,运转thenecho"$userhaslogged"else训令履行挫折,$?为1,运转elseecho"$userhasnotlogged"fishtest.shinput:macgmacgpts/0May1515:55.2075(192.168.1.100)macghasloggedshtest.shinput:ddddddhasnotlogged以因变量当做if环境(因变量就一定于command,因变量的长处是其return值得以自界说)if以因变量当做if环境,getynthen因变量reture值0为真,走thenecho"youranswerisyes"else因变量return值非0为假,走elseecho"youranserisno"fiifcommand等价于command+if$?$vitestsh.sh!/bin/shifcat111-tmp.txt|grepting1thenechofoundelseecho"nofound"fi$vitestsh.sh!/bin/shcat111-tmp.txt|grepting1if$?-eq0thenecho$?echofoundelseecho$?echo"nofound"fi$shtestsh.shnofound$shtestsh.sh1nofound$vi111-tmp.txtthatis222filethisting1is111file$shtestsh.shthisting1is111filefound$vi111-tmp.txtthatis222filethisting1is111file$shtestsh.shthisting1is111file0found以环境抒发式当做if环境价值观if从句——以环境抒发式当做if环境if环境抒发式thencommandcommandcommandelsecommandcommandfi环境抒发式文书抒发式if-ffile如其文书在if-d...如其目次在if-sfile如其文书在且非空if-rfile如其文书在且可读if-wfile如其文书在且可写if-xfile如其文书在且可履行平头变量抒发式ifint1-eqint2如其int1对等int2ifint1-neint2如其不对等ifint1-geint2如其>=ifint1-gtint2如其>ifint1-leint2如其<=ifint1-ltint2如其<字符串变量抒发式If$a=$b如其string1对等string2字符串容许应用赋值号做等号if$string1!=$string2如其string1不对等string2if-n$string如其string非空(非0),归来0(true)if-z$string如其string为空if$sting如其string非空,归来0(和-n类似)环境抒发式引证变量要带$ifa=b;thenechoequalelseechonoequalfimacg@machome~$shtest.shinputa:5inputb:5noequal(对等抒发式没比$a和$b,而是比和a和b,天然a!=b)纠正:if$a=$b;thenechoequalelseechonoequalfimacg@machome~$shtest.shinputa:5inputb:5equal-eq-ne-lt-nt不得不用来平头,不快用来字符串,字符串对等用赋值号=macg@machome~$vitest.shecho-n"inputyourchoice:"readvarif$var-eq"yes"thenecho$varfimacg@machome~$sh-xtest.shinputyourchoice:ytest.sh:line3:test:y:integerexpression_r_r_rexpected期望平头式,即-eq不撑持字符串=放在别的地域是赋值,放在if里即字符串对等,shell里没==的,那是c言语的对等无空格的字符串,得以加"",也得以不加macg@machome~$vitest.shecho"inputa:"readaecho"inputis$a"if$a=123;thenechoequal123fimacg@machome~$shtest.shinputa:123inputis123equal123=当做对等时,其两边都务须加空格,要不失灵等号也是操作符,务须和其它变量,关头字,用空格格开(等号做赋值号时正好反而,两边不许有空格)macg@machome~$vitest.shecho"inputyourchoice:"readvarif$var="yes"thenecho$varecho"inputiscorrect"elseecho$varecho"inputerror"fimacg@machome~$vitest.shecho"inputyourchoice:"readvarif$var="yes"在等号两边加空格thenecho$varecho"inputiscorrect"elseecho$varecho"inputerror"fimacg@machome~$shtest.shinputyourchoice:yyinputiscorrectmacg@machome~$shtest.shinputyourchoice:nninputiscorrect输错了也走then,都走then,干吗?因if把$var="yes"连读成一个变量,而此变量为空,归来1,则走elsemacg@machome~$shtest.shinputyourchoice:yyinputerrormacg@machome~$shtest.shinputyourchoice:nonoinputerror所如同常If$ANS等价于if-n$ANS如其字符串变量非空(then),空(else)echo"inputyourchoice:"readANSif$ANSthenechonoemptyelseechoempthfimacg@machome~$shtest.shinputyourchoice:回车empth介绍回车即空串macg@machome~$shtest.shinputyourchoice:34noempty平头环境抒发式,大于,小于,shell里没>和<,会被当做尖括号,除非-ge,-gt,-le,ltmacg@machome~$vitest.shecho"inputa:"readaif$a-ge100;thenecho3bitelseecho2bitfimacg@machome~$shtest.shinputa:1233bitmacg@machome~$shtest.shinputa:202bit平头操作记号-ge,-gt,-le,-lt,别忘了加-iftest$age100;thenmacg@machome~$shtest.shtest.sh:line4:test:ge:binaryoperatorexpectediftest$a-ge100;thenmacg@machome~$shtest.shinputa:1233bit论理抒发式论理非!环境抒发式的反而if!抒发式if!-d$num如其不在目次$num论理与–a环境抒发式的并重if抒发式1–a抒发式2论理或-o环境抒发式的或if抒发式1–o抒发式2论理抒发式抒发式与前的=!=-d–f–x-ne-eq-lt等合用论理记号就如常的接其它抒发式,没任何括号(),即并重if-z"$JHHOME"-a-d$HOME/$num留意论理与-a与论理或-o很易于和其它字符串或文书的演算记号搞混了最常见的赋值式,赋值前对=两边的变量都进展评测左首测变量是不是为空,右首测目次(值)是不是在(值是不是有效)macg@mac-home~$vitest.sh:echo"inputthenum:"readnumecho"inputis$num"if-z"$JHHOME"-a-d$HOME/$num如其变量$JHHOME为空,且$HOME/$num目次在thenJHHOME=$HOME/$num则赋值fiecho"JHHOMEis$JHHOME"\-----------------------macg@mac-home~$shtest.shinputthenum:pppinputispppJHHOMEis目次-d$HOME/$num不在,因而$JHHOME没被then赋值macg@mac-home~$mkdirpppmacg@mac-home~$shtest.shinputthenum:pppinputispppJHHOMEis/home/macg/ppp一个-o的案例,内中却揭示了=务须两边留空格的情况echo"inputyourchoice:"readANSif$ANS="Yes"-o$ANS="yes"-o$ANS="y"-o$ANS="Y"thenANS="y"elseANS="n"fiecho$ANSmacg@machome~$shtest.shinputyourchoice:nymacg@machome~$shtest.shinputyourchoice:noy干吗进口不是yes,后果仍是y(走then)因=被连读了,成了变量$ANS="Yes",而变量又为空,因而走else了macg@machome~$vitest.shecho"inputyourchoice:"readANSecho"inputyourchoice:"readANSif$ANS="Yes"-o$ANS="yes"-o$ANS="y"-o$ANS="Y"thenANS="y"elseANS="n"fiecho$ANSmacg@machome~$shtest.shinputyourchoice:nonmacg@machome~$shtest.shinputyourchoice:yesymacg@machome~$shtest.shinputyourchoice:yy以test环境抒发式当做if环境iftest$num-eq0等价于if$num–eq0test抒发式,没iftest$num-eq0thenecho"tryagain"elseecho"good"fimantestmacg@machome~$mantest(1)UserCommands(1)SYNOPSIStestEXPRESSIONEXPRESSION-nSTRINGthelengthofSTRINGisnonzero-n和径直$str都好坏0环境-zSTRINGthelengthofSTRINGiszeroSTRING1=STRING2thestringsareequalSTRING1!=STRING2thestringsarenotequalINTEGER1-eqINTEGER2INTEGER1isequaltoINTEGER2INTEGER1-geINTEGER2INTEGER1isgreaterthanorequaltoINTEGER2INTEGER1-gtINTEGER2INTEGER1isgreaterthanINTEGER2INTEGER1-leINTEGER2INTEGER1islessthanorequaltoINTEGER2INTEGER1-ltINTEGER2INTEGER1islessthanINTEGER2INTEGER1-neINTEGER2INTEGER1isnotequaltoINTEGER2FILE1-ntFILE2FILE1isnewer(modificationdate)thanFILE2FILE1-otFILE2FILE1isolderthanFILE2-bFILEFILEexistsandisblockspecial-cFILEFILEexistsandischaracterspecial-dFILEFILEexistsandisadirectory-eFILEFILEexists文书在-fFILEFILEexistsandisaregularfile文书在且是一般文书-hFILEFILEexistsandisasymboliclink(sameas-L)-LFILEFILEexistsandisasymboliclink(sameas-h)-GFILEFILEexistsandisownedbytheeffectivegroupID-OFILEFILEexistsandisownedbytheeffectiveuserID-pFILEFILEexistsandisanamedpipe-sFILEFILEexistsandhasasizegreaterthanzero-SFILEFILEexistsandisasocket-wFILEFILEexistsandiswritable-xFILEFILEexistsandisexecutableif简化文句最常用的简化if文句&&如其是前,则后-f/var/run/dhcpd.pid&&rm/var/run/dhcpd.pid检讨文书是不是在,如其在就删掉||如其不是前,则后-f/usr/sbin/dhcpd||exit0检验文书是不是在,如其在就退出用简化if和$1,$2,$3来检测参数,不有理就调用help-z"$1"&&help如其头个参数不在(-z字符串长度为0)"$1"="-h"&&help如其头个参数是-h,就显得help案例!/bin/sh-f"/etc/sysconfig/network-scripts/ifcfg-eth0"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth0cpifcfg-eth0.bridge/etc/sysconfig/network-scripts/ifcfg-eth0-f"/etc/sysconfig/network-scripts/ifcfg-eth1"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth1cpifcfg-eth1.bridge/etc/sysconfig/network-scripts/ifcfg-eth1-f"/etc/sysconfig/network-scripts/ifcfg-eth0:1"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth0:1您可能性感兴味的篇:Shell中exit和return的区分讲授在Shell本子中调用另一个本子的三种方式讲授应用shell足原来给mysql加目的法子干掉一堆mysql数据库,仅需这么一个shell本子(引荐)linuxshell之经过标识测试文书系特性的法子示范linuxshell之pushd、popd和dirs的应用讲授linuxshell之统制台盖章各种颜料书体和背景的兑现法子shell本子兑现监控某过程万一终止后拉起过程应用shell本子每日对MySQL多个数据库机动备份的讲授应用shell来发tcp包的法子,shell编程中应用到得if文句内断定参数–b当file在而且是块文书时归来真-c当file在而且是字符文书时归来真-d当pathname在而且是一个目次时归来真-e当pathname指定的文书或目次在时归来真-f当file在而且是正式文书时归来真-g当由pathname指定的文书或目次在而且设立了SGID位时归来为真-h当file在而且是记号链接文书时归来真,该选项在一部分老系上无用-k当由pathname指定的文书或目次在而且设立了粘滞位时归来真-p当file在而且是下令管道时归来为真-r当由pathname指定的文书或目次在而且可读时归来为真-s当file在文书老幼大于0时归来真-u当由pathname指定的文书或目次在而且设立了SUID位时归来真-w当由pathname指定的文书或目次在而且可履行时归来真。

      -ne不对等则为真。

      -gt大于则为真。

      履行,并查阅情况。

      bash-xtijian.sh60170+weight=60+height=170+idealweight=60+\60-le60\+echoYoushouldeatabitmorefat.Youshouldeatabitmorefat.内中-x用来检讨本子的履行市况if文句格式if环境thenCommandelseCommandfi别忘了这结尾if文句忘了结尾fitest.sh:line14:syntaxerror:unexpectedendoffiif的三种环境抒发式ifcommandthenif因变量then下令履行胜利,对等归来0(例如grep,找到配合)履行挫折,归来非0(grep,没找到配合)ifexpression_r_r_rthen抒发式后果为真,则归来0,if把0值引向theniftestexpression_r_r_rthen抒发式后果为假,则归来非0,if把非0值引向then&&——快捷if-f"/etc/shadow"&&echo"Thiscomputerusesshadowpasswors"&&得以了解为then如其左首的抒发式为真则履行右首的文句shell的if与c言语if的作用上的区分shellifc言语if0为真,走then正好反而,非0走then不撑持平头变量径直if务须:ifi–ne0但是撑持字符串变量径直ififstr如其字符串非0撑持变量径直ifif(i)以command当做if环境以多条command或因变量当做if环境echo–ninput:readuserif多条训令,这些下令之间一定于and(与)grep$user/etc/passwd>/tmp/nullwho-u|grep$userthen上头的训令都履行胜利,归来值$?为0,0为真,运转thenecho"$userhaslogged"else训令履行挫折,$?为1,运转elseecho"$userhasnotlogged"fishtest.shinput:macgmacgpts/0May1515:55.2075(192.168.1.100)macghasloggedshtest.shinput:ddddddhasnotlogged以因变量当做if环境(因变量就一定于command,因变量的长处是其return值得以自界说)if以因变量当做if环境,getynthen因变量reture值0为真,走thenecho"youranswerisyes"else因变量return值非0为假,走elseecho"youranserisno"fiifcommand等价于command+if$?$vitestsh.sh!/bin/shifcat111-tmp.txt|grepting1thenechofoundelseecho"nofound"fi$vitestsh.sh!/bin/shcat111-tmp.txt|grepting1if$?-eq0thenecho$?echofoundelseecho$?echo"nofound"fi$shtestsh.shnofound$shtestsh.sh1nofound$vi111-tmp.txtthatis222filethisting1is111file$shtestsh.shthisting1is111filefound$vi111-tmp.txtthatis222filethisting1is111file$shtestsh.shthisting1is111file0found以环境抒发式当做if环境价值观if从句——以环境抒发式当做if环境if环境抒发式thencommandcommandcommandelsecommandcommandfi环境抒发式文书抒发式if-ffile如其文书在if-d...如其目次在if-sfile如其文书在且非空if-rfile如其文书在且可读if-wfile如其文书在且可写if-xfile如其文书在且可履行平头变量抒发式ifint1-eqint2如其int1对等int2ifint1-neint2如其不对等ifint1-geint2如其>=ifint1-gtint2如其>ifint1-leint2如其<=ifint1-ltint2如其<字符串变量抒发式If$a=$b如其string1对等string2字符串容许应用赋值号做等号if$string1!=$string2如其string1不对等string2if-n$string如其string非空(非0),归来0(true)if-z$string如其string为空if$sting如其string非空,归来0(和-n类似)环境抒发式引证变量要带$ifa=b;thenechoequalelseechonoequalfimacg@machome~$shtest.shinputa:5inputb:5noequal(对等抒发式没比$a和$b,而是比和a和b,天然a!=b)纠正:if$a=$b;thenechoequalelseechonoequalfimacg@machome~$shtest.shinputa:5inputb:5equal-eq-ne-lt-nt不得不用来平头,不快用来字符串,字符串对等用赋值号=macg@machome~$vitest.shecho-n"inputyourchoice:"readvarif$var-eq"yes"thenecho$varfimacg@machome~$sh-xtest.shinputyourchoice:ytest.sh:line3:test:y:integerexpression_r_r_rexpected期望平头式,即-eq不撑持字符串=放在别的地域是赋值,放在if里即字符串对等,shell里没==的,那是c言语的对等无空格的字符串,得以加"",也得以不加macg@machome~$vitest.shecho"inputa:"readaecho"inputis$a"if$a=123;thenechoequal123fimacg@machome~$shtest.shinputa:123inputis123equal123=当做对等时,其两边都务须加空格,要不失灵等号也是操作符,务须和其它变量,关头字,用空格格开(等号做赋值号时正好反而,两边不许有空格)macg@machome~$vitest.shecho"inputyourchoice:"readvarif$var="yes"thenecho$varecho"inputiscorrect"elseecho$varecho"inputerror"fimacg@machome~$vitest.shecho"inputyourchoice:"readvarif$var="yes"在等号两边加空格thenecho$varecho"inputiscorrect"elseecho$varecho"inputerror"fimacg@machome~$shtest.shinputyourchoice:yyinputiscorrectmacg@machome~$shtest.shinputyourchoice:nninputiscorrect输错了也走then,都走then,干吗?因if把$var="yes"连读成一个变量,而此变量为空,归来1,则走elsemacg@machome~$shtest.shinputyourchoice:yyinputerrormacg@machome~$shtest.shinputyourchoice:nonoinputerror所如同常If$ANS等价于if-n$ANS如其字符串变量非空(then),空(else)echo"inputyourchoice:"readANSif$ANSthenechonoemptyelseechoempthfimacg@machome~$shtest.shinputyourchoice:回车empth介绍回车即空串macg@machome~$shtest.shinputyourchoice:34noempty平头环境抒发式,大于,小于,shell里没>和<,会被当做尖括号,除非-ge,-gt,-le,ltmacg@machome~$vitest.shecho"inputa:"readaif$a-ge100;thenecho3bitelseecho2bitfimacg@machome~$shtest.shinputa:1233bitmacg@machome~$shtest.shinputa:202bit平头操作记号-ge,-gt,-le,-lt,别忘了加-iftest$age100;thenmacg@machome~$shtest.shtest.sh:line4:test:ge:binaryoperatorexpectediftest$a-ge100;thenmacg@machome~$shtest.shinputa:1233bit论理抒发式论理非!环境抒发式的反而if!抒发式if!-d$num如其不在目次$num论理与–a环境抒发式的并重if抒发式1–a抒发式2论理或-o环境抒发式的或if抒发式1–o抒发式2论理抒发式抒发式与前的=!=-d–f–x-ne-eq-lt等合用论理记号就如常的接其它抒发式,没任何括号(),即并重if-z"$JHHOME"-a-d$HOME/$num留意论理与-a与论理或-o很易于和其它字符串或文书的演算记号搞混了最常见的赋值式,赋值前对=两边的变量都进展评测左首测变量是不是为空,右首测目次(值)是不是在(值是不是有效)macg@mac-home~$vitest.sh:echo"inputthenum:"readnumecho"inputis$num"if-z"$JHHOME"-a-d$HOME/$num如其变量$JHHOME为空,且$HOME/$num目次在thenJHHOME=$HOME/$num则赋值fiecho"JHHOMEis$JHHOME"\-----------------------macg@mac-home~$shtest.shinputthenum:pppinputispppJHHOMEis目次-d$HOME/$num不在,因而$JHHOME没被then赋值macg@mac-home~$mkdirpppmacg@mac-home~$shtest.shinputthenum:pppinputispppJHHOMEis/home/macg/ppp一个-o的案例,内中却揭示了=务须两边留空格的情况echo"inputyourchoice:"readANSif$ANS="Yes"-o$ANS="yes"-o$ANS="y"-o$ANS="Y"thenANS="y"elseANS="n"fiecho$ANSmacg@machome~$shtest.shinputyourchoice:nymacg@machome~$shtest.shinputyourchoice:noy干吗进口不是yes,后果仍是y(走then)因=被连读了,成了变量$ANS="Yes",而变量又为空,因而走else了macg@machome~$vitest.shecho"inputyourchoice:"readANSecho"inputyourchoice:"readANSif$ANS="Yes"-o$ANS="yes"-o$ANS="y"-o$ANS="Y"thenANS="y"elseANS="n"fiecho$ANSmacg@machome~$shtest.shinputyourchoice:nonmacg@machome~$shtest.shinputyourchoice:yesymacg@machome~$shtest.shinputyourchoice:yy以test环境抒发式当做if环境iftest$num-eq0等价于if$num–eq0test抒发式,没iftest$num-eq0thenecho"tryagain"elseecho"good"fimantestmacg@machome~$mantest(1)UserCommands(1)SYNOPSIStestEXPRESSIONEXPRESSION-nSTRINGthelengthofSTRINGisnonzero-n和径直$str都好坏0环境-zSTRINGthelengthofSTRINGiszeroSTRING1=STRING2thestringsareequalSTRING1!=STRING2thestringsarenotequalINTEGER1-eqINTEGER2INTEGER1isequaltoINTEGER2INTEGER1-geINTEGER2INTEGER1isgreaterthanorequaltoINTEGER2INTEGER1-gtINTEGER2INTEGER1isgreaterthanINTEGER2INTEGER1-leINTEGER2INTEGER1islessthanorequaltoINTEGER2INTEGER1-ltINTEGER2INTEGER1islessthanINTEGER2INTEGER1-neINTEGER2INTEGER1isnotequaltoINTEGER2FILE1-ntFILE2FILE1isnewer(modificationdate)thanFILE2FILE1-otFILE2FILE1isolderthanFILE2-bFILEFILEexistsandisblockspecial-cFILEFILEexistsandischaracterspecial-dFILEFILEexistsandisadirectory-eFILEFILEexists文书在-fFILEFILEexistsandisaregularfile文书在且是一般文书-hFILEFILEexistsandisasymboliclink(sameas-L)-LFILEFILEexistsandisasymboliclink(sameas-h)-GFILEFILEexistsandisownedbytheeffectivegroupID-OFILEFILEexistsandisownedbytheeffectiveuserID-pFILEFILEexistsandisanamedpipe-sFILEFILEexistsandhasasizegreaterthanzero-SFILEFILEexistsandisasocket-wFILEFILEexistsandiswritable-xFILEFILEexistsandisexecutableif简化文句最常用的简化if文句&&如其是前,则后-f/var/run/dhcpd.pid&&rm/var/run/dhcpd.pid检讨文书是不是在,如其在就删掉||如其不是前,则后-f/usr/sbin/dhcpd||exit0检验文书是不是在,如其在就退出用简化if和$1,$2,$3来检测参数,不有理就调用help-z"$1"&&help如其头个参数不在(-z字符串长度为0)"$1"="-h"&&help如其头个参数是-h,就显得help案例!/bin/sh-f"/etc/sysconfig/network-scripts/ifcfg-eth0"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth0cpifcfg-eth0.bridge/etc/sysconfig/network-scripts/ifcfg-eth0-f"/etc/sysconfig/network-scripts/ifcfg-eth1"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth1cpifcfg-eth1.bridge/etc/sysconfig/network-scripts/ifcfg-eth1-f"/etc/sysconfig/network-scripts/ifcfg-eth0:1"&&rm-f/etc/sysconfig/network-scripts/ifcfg-eth0:1,shellifShell言语中的if条件一、if的根本语法:ifcommand;then吻合该条件履行的文句elifcommand;then吻合该条件履行的文句else吻合该条件履行的文句fi二、文书/文书夹(目次)断定-bFILE如其FILE在且是一个块特殊文书则为真。

      撑持使用与或非将抒发式连兴起。

      不论是字符串比抑或平头比都万万不要使用大于号小于号。

      履行,并查阅情况。

      字符串比时得以把右首的当做一个模式(这是右首的字符串不加双引号的情形下。

      履行,并查阅情况。

      -z字串字串长度伪则为真。

      -xFILE如其FILE在且是可履行的则为真。

      2.构造比Bash本子的更通用。

      自然,如其你委实想用也是得以的,对字符串比得以使用尖括号的转义式,如其比"ab"和"bc":ab\

      例:"a"!="b"&&10>2断定后果就不如常。