注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

牧笔临风

己有能,勿自私!

 
 
 

日志

 
 
 
 

shell 逻辑运算  

2010-08-22 18:05:58|  分类: shell脚本 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
文件比较运算符:
-e filename 如果 filename 存在,则为真 [ -e /var/log/syslog ]
-d filename 如果 filename 为目录,则为真 [ -d /tmp/mydir ]
-f filename 如果 filename 为常规文件,则为真 [ -f /usr/bin/grep ]
-L filename 如果 filename 为符号链接,则为真 [ -L /usr/bin/grep ]
-r filename 如果 filename 可读,则为真 [ -r /var/log/syslog ]
-w filename 如果 filename 可写,则为真 [ -w /var/mytmp.txt ]
-x filename 如果 filename 可执行,则为真 [ -L /usr/bin/grep ]
filename1 -nt filename2 如果 filename1 比 filename2 新,则为真 [ /tmp/install/etc/services -nt /etc/services ]
filename1 -ot filename2 如果 filename1 比 filename2 旧,则为真 [ /boot/bzImage -ot arch/i386/boot/bzImage ]

字符串比较运算符:请注意引号的使用,这是防止空格扰乱代码的好方法
-z string 如果 string 长度为零,则为真 [ -z "$myvar" ]
-n string 如果 string 长度非零,则为真 [ -n "$myvar" ]
string1 = string2 如果 string1 与 string2 相同,则为真 [ "$myvar" = "one two three" ]
string1 != string2 如果 string1 与 string2 不同,则为真 [ "$myvar" != "one two three" ]

算术比较运算符:
num1 -eq num2 等于 [ 3 -eq $mynum ]
num1 -ne num2 不等于 [ 3 -ne $mynum ]
num1 -lt num2 小于 [ 3 -lt $mynum ]
num1 -le num2 小于或等于 [ 3 -le $mynum ]
num1 -gt num2 大于 [ 3 -gt $mynum ]
num1 -ge num2 大于或等于 [ 3 -ge $mynum ]
  评论这张
 
阅读(412)| 评论(0)
\"\>\t/"字符\>iv&g ztag">
文件比较\ re;\ eace:pre;&q 将\" /> \"\>\t/"字符\>t;/span>[ tspace:pre;&quo 将\" /> \"\>\t/"字符\>iv&;-d filename&l pre;\ re;\ e-space:pre 将\" /> \"\>\t/"字符\>t;/span>[ t为te-space:pre;&qu 将\" /> \"\>\t/"字符\>iv&filename<span pre;\ re;\ epre;" 将\" /> \"\>\t/"字符\>t;/span>[ t为space:pre;" 将\" /> \"\>\t/"字符\>iv&filename<span pre;\ re;\ epre;" pre;\ ',吧ㄒ簧ā3.c:'',吧ㄒ簧ā &l:an> ,吧ㄒ簧ā:fawid,吧ㄒ簧ā-Ids:[],吧ㄒ簧ā ,吧ㄒ簧ā:fawid,吧ㄒ簧ā _ftegl 'givwc hf"fls lose">   蝡an> "display:none" analysan>phian> _ftegl <\'+"di D   lf.nosdniv 7tyle= /TlZCWHdFWFpidkQ1dGtJK1N5cFRBNzBLUFFPYnJEVi9LWk1KTzJlMTU2Yz0.jpg"v> '吧ㄒ簧ā {lnbs a as x _heigh{if !!x _heighip" cclose"> vwc hf"fls l 蝡an> ${x.visip pNne"}om/吧ㄒ簧ā{if x.visip pNne"==visip p.u${x.visip pNickone"|escape}" rror id="siv c=0" margi.focum swdass=a="prig ${fn1(x.visip pNne")}&r=${visip p.:noneUpd 吧ㄒ簧ā{.wid _heigheig ale">${x.visip pNickone"|escape}" rror id="siv c=0" margi.focum swdass=a="prig ${fn1(x.visip pNne")}"v>吧ㄒ簧ā{6e; _heigheig.163.com/" 吧ㄒ簧ā {if x.msp;F =='wap' _heighei="t0giv> p" cl="sclose"> vw0" allowtrannb>蝡an> v>
f/wapnb>蝡html? logscrcomb>蝖o!ess=字符
来自希手机博客um an> s=字符
来自iPh 客户端um an> p" cl="sclose"> s=字符
来自Android客户端um an>  " />iclas lose">  c hf"fls l 蝡an> ${x.visip pNne"}om/吧ㄒ簧ā="t0${fn(x.visip pNickone",8)|escape}吧ㄒ簧āt0gp> pre;>吧ㄒ簧 pre;>吧ㄒ簧{6e; _heigh{ix"st _hei {if !!a _heighgivose">  蝡an> ${a.ugp> givose">  " />iclas 蝡an> ${a.u gv&gm i博rlogse6">${ss=[at260}${su id }{6e; pre;>吧 pnt pn " />ifts=axian >gp> t0gpv&g>吧ㄒ簧{6e; _heiss吧ㄒ簧{lnbs a as x _heigh{if !!x _heigh< ]givose">  " />iclas ">${fn(x. {6e; _hei {ix"st _hei " /6">e力凉馄猯og-的人iv> v&g>吧ㄒ簧 {lnbs a as x _heigh {if !!x _height0gv&gm an> " />ip" cclose"> vwc hf"fls l 蝡an> ${x.re <${x.re <吧ㄒ簧āt0gp> t0gv&gm cwda]吧ㄒ簧ā t0giv> " />iclas ose">  c hf"fls l 蝡an> ${x.re < t0gpv&g>吧ㄒ簧 gpv&g>吧ㄒ簧 {6e; _hei {ix"st _heit0gpv&g>吧ㄒ簧{if !!b&&b. gth>0 _heighgp m " /6">他们还e力亮薸v> class="fc{lnbs b as y _heighei{if !!y _heigheit0g rrbss=字符 an> " />iclas ose">  0" allowtrannb>蝡an> ${y.re <蜳erm nk}/? "240" class="shareitm weixin f-bkic">${y.re <蝟m/bl|escape}gp> {ie; _heigh{ix"st _heit0gpclass="fc{ie; _hei <字符 id="$" / c-詂记录840670850吧ㄒ簧<>吧ㄒ簧āt0 &l}">${x.0" erBb>蝟m/bl|escape}gp> 字符 ppv&g>吧ㄒ簧 t0gv&gm enr id="ss=字符ght="0" marginwidth= " / axian ${x.0" er 字符 ppv&g>吧ㄒ簧 {6x"st _heit0gpclass=" {lnbs a as x _heigh{if !!x _heigh< ]givose">  " />iclas 蝡an> ${x.u蝐lo/div> ${x.o/div| hfaLin:""|escape}">${x.o/div| hfaLin:""|escape}gp> {ie; _heigh{ix"st _heigivose">  " />iclas 蝡an> ${x.u"lo/div> ${x.o/div| hfaLin:""|escape}">${x.o/div| hfaLin:""|escape}gp> {ie; _heigh{ix"st _heigivose">  " />iclas ose">  0" al${x.bb> &l| hfaLin:""|escape}?re <o/div> ${x.bb>蜹wi | hfaLin:""|escape}">${x.bb>蜹wi | hfaLin:""|escape}gp> {ie; _heigh{ix"st _hei< 吧ㄒ簧 {lnbs a as x _heigh {if x_ ex>4}{b>[ak}{6e; 吧ㄒ簧ā{if !!x _heigh="t0g ]ss吧ㄒ簧ā="t0giv> clas ose">  o/div> ${x.o/div| hfaLin:""|escape}">${fn1(x.o/div,60)|escape}gp> 字符 " / ${fn2(x. < 吧ㄒ {lnbs a as x _heigh{if !!x _heigh< ]givose">  " />iclas ${fn(x.o/div,26)|escape}gp> {6e; _hei {ix"st _hei {if !!(bb>蜠t="27. Bb>蜳erm nk) _heighei> il an>giv clas 蜳erm nk}om/${bb>蜠t="27. Bb>蜹/div|escape}gp> v&g>吧ㄒ簧 {ie; _heigh {if !!(bb>蜠t="27.noftBb>蜳erm nk) _heighei> irt;/an>中giv clas 蜳erm nk}om/${bb>蜠t="27.noftBb>蜹/div|escape}gp> v&g>吧ㄒ簧 {ie; _heiss吧ㄒ簧{lnbs a as x _heigh{if !!x _heigh " />ip" cclose"> vwc hf"fls l 蝡an> ${x. ${x. 吧ㄒ簧ā{.wid _heigheig ale">${x. 吧ㄒ簧ā{6e; _heigheig.163.com/" 吧ㄒ簧ā giv> " />iclas ose">  c hf"fls l 蝡an> ${x. gpv&g>吧ㄒ簧 giv> "-myLikeI="m- hoo {if x. =1} js-like {.widif x. =2} js-rdnb> {.widif x. =3} js-> {.wid}{6e; close"> vwc hf"fls l 蝡an> ${x. gpv&g>吧ㄒ簧{ie; _heigh{ix"st _hei 希新闻gpv&g>吧ㄒ簧t0000000gv&gm "disoidd 吧ㄒ簧 t000000000giv> h "dis5%AE%A2%E5%85%B3%E9ose">  0" al${h s.id=_3w|escape}d 吧 > &nbg icons${ size(h s. src,hei,150,tru")}" 吧 > &nbg字符 icsp;rss="字符 > &nbg字符 i84074"字符 imgtylca]${h s.o/div|escape}04字符 p"字符 >t0000000gp> 吧 >t0000000g>< 吧 >t0000000 {if hf d('"disx"st')&playsx"st. gth>0 _height0000000t0000000{lnbs laysx"st as x _height0t0000000t00000{if x_ ex>7}{b>[ak}{6e; 吧 >t0000000 00g ]  >t0000000 00{ix"st _heit0000000t00000 {ie; _h >t0000000gpclass >t0000000gv&gm nt" lhrr63.com/r?吧 >t0000000t000giv> " /AF%ose">  c hf"fls l t0000000gpv&g>吧ㄒ簧t0000000gpv&g>吧ㄒ[ deearfdive>[ -cut吧ㄒ簧 pre;"> t000gh4T " / aap" ltst 被e力羖og-" t4"吧ㄒ簧<> 最新log-" t4"吧ㄒ簧<> 该作者的其他163." t4"吧ㄒ簧<> 博主e力" t4"吧ㄒ簧<> 随机bar " t4"吧ㄒ簧<> 首页e力" t4"吧ㄒ簧<>  " /class="pleft"> bb> 63.. ">更多lenamlt;04 stav&gd t000gbrv>gbrv>吧ㄒ簧gv&gmearfyod hrr_t">转发至 _zoom:1> gpv&g>吧ㄒ簧gv&gmearfan> _ftegl es="v&g>吧ㄒ簧gv&gmearfbb>蜳ublncAcc ="v&g>吧ㄒ[ deearfdive>[ -6"> gv&gm
pre;"> t000gv&gm ss=iv> 0 "> 95082085084yod hrr_2eT

将蝊zoom:1> gpre;"> ="t0gv&gm 登录 bs=iv> 0 "> d 吧ㄒ簧 gv&gm cifres="v&g>吧ㄒ簧00gv&gm p;

="v&g>吧ㄒ00g"v&g>吧ㄒ[ -6"> gv&gm clofres吧ㄒ簧ā= 吧 0gv&gm 登录 950820s="v&g>吧ㄒ[ ->ss吧ㄒ簧{lnbs a as x _heigh{if !!x _heigh00glis吧ㄒ簧ā=ivw0" allowtrannb>蝡an> ${x.u  clas" />ss${x.defoNne"|escape}gp> .lofter.com/投票给吧ㄒ簧ā= {b-mcfir> op/div r tru"; _heighei> {lnbs x.vid=Dt="27Lnbs as vid=ToOp/div _heighei> t000{if vid=ToOp/div==1}吧ㄒ簧ā= t00000{if fir> op/div==fawid},{ie; .lofter.com/“${b[vid=ToOp/div_ ex]}”.lofter.com/吧ㄒ簧ā= t000{ie; _heigh0000{ix"st _hei000000{if (x.role!="-6") },“我是${c[x.role]}”.lofter.com/{ie; _heigh0000.lofter.com/.lofter.com/ 吧_20span>[ 3 -ge $mynum ]
63.. /Btn_weixin2" /bb> class="shareitm weixin f-bkic/"; //163.的永久lename作为163.的蝖tt标识吧b-mc 3.cs r "; //163.ks_08杂⑽亩汉欧指簦纾"ks_01,ks_02"吧b-mc Siv>P0" ix r bb> 63.. /Btn_weixin2" /"; //博客的主页地址,作为博客的蝖tt标识吧b-mc Params r &<=5&mose=3&pf"240"63."; //<spa舷允-的相关163.数目,mosespa系南允-模式(1为16字,2为图 长3为自动)_201span>[s吧0span>[ 3 -ge $mynum ]
con. . /oft/>
. 大);吧ㄒ簧}吧="span>[s吧吧="v&g>吧ㄒ簧00gv&gm c .loftegpv&g>吧ㄒ簧00gv&gm r cr h"> c .loftegpv&g>吧ㄒ簧="v&g>吧ㄒ簧gv&gm _t"mb lcr bh 字穋res吧ㄒ簧āgv&gm l bl bhc .loftegpv&g>吧ㄒ簧00gv&gm r br bhc .loftegpv&g>吧ㄒ簧00gv&gm s="s="h lcrc .loftegpv&g>吧ㄒ簧="v&g>吧ㄒ="v&g>吧吧="v&g>吧ㄒ簧00gv&gm c .loftegpv&g>吧ㄒ簧00gv&gm 吧ㄒ簧00gv&gm c .loftegpv&g>吧ㄒ簧00gv&gm mc r t yxp..lofte="v&g>吧000000gv&gm mc r b rbss.lofte="v&g>吧0000="v&g>吧00="v&g>吧00=v&gm _t"se s -smbss=v&gm wkg h 字穋res=v&gm hss.lofte="v&g>=v&gm r hss.lofte="v&g>=v&gm c hss.lofte="v&g>="v&g>="v&g>吧=v&gm _t"se s -fodd 吧ㄒ=v&gm wkg hes吧ㄒ簧

页絫c h2>吧ㄒ簧=v&gm k">000000ga > ="nog" hreum clas" /8F%ose">  w0" allowtranblank" href="http://wwwgp> 吧000000g字符 "edi1cut-="s址 000000ga > ="nog" hreum clas" /8F%ose">  w0" allowtranbb> 63.. / c/thd om/博客风格gp> 吧000000g字符 "edi1cut-="s址 000000ga > ="nog" hreum clas" /8F%ose">  w0" allowtranbb> 63.. /v>
f/wapnb>蝡html">手机博客gp> 吧000000g字符 "edi1cut-="s址 000000ga > ="nog" hreum clas" /8F%ose">  w0" allowtran 209_06"> 吧000000吧ㄒ簧āglink > ="aleemonv>n "laslnca/div/rss+xmcclo/div> RSS于 吧ㄒ簧ā 中 clas" /8F>订阅此博客gp> ="s址 0000="v&g>吧0000 " /8 希公司版权所有.lofte©1997- 7> ="v&g>吧="v&g>="v&g>吧0000