[FZH] bash中如何测试子字符串?

Chen Lei supercyper在163.com
星期二 四月 20 09:28:55 UTC 2010


test -f /usr/share/ibus/ui/panel.py &&  test "x$DESKTOP_SESSION" = "xkde"


在2010-04-20 17:24:20,"Chen Lei" <supercyper在163.com> 写道:
>
>
>你的处理方法有问题。。。
>直接 test $DESKTOP_SESSION是否于kde相等不就可以了么
>test -f /usr/libexec/panel.py && test -f /usr/bin/kimpanel;->test -f /usr/libexec/panel.py 
>因为panel.py 必须依赖kimpanel
>另外panel.py这么常见的名字不要直接放在libexec下面啊,而且这个不是libexec,应该是没有shebang的文件
>
>在2010-04-20 17:07:08,"李瑞彬" <cheeseli在hotmail.com> 写道:
>>>参看这个bug:https://bugzilla.redhat.com/show_bug.cgi?id=583716> >也是关于Kimpanel的>  >> Date: Tue, 20 Apr 2010 17:04:51 +0800 >> From: supercyper在163.com >> To: chinese在lists.fedoraproject.org >> Subject: Re: [FZH] bash中如何测试子字符串?>>  >> 寻找kde字符串是想干嘛?>> >> >>  >>  >> 在2010-04-20 14:13:55,"LI Rui Bin" <cheeseli在hotmail.com> 写道: >> >目前使用 >> >echo $VAR|grep -i kde >/dev/null >> > >> >On 04/20/2010 01:44 PM, dhyang wrote: >> >> 在 2010-04-20二的 01:04 +0800,LI Rui Bin写道: >> >> >> >>> 翻了一下书 >> >>> 也可以 test -z ${VAR##*kde*} >> >>>  >> >> bash的字符截断,也可以这样 test -z ${VAR%%*kde*},往后截断,不过写作 >> >> [ -z ${VAR##*kde*}] 会比较专业一些。 >> >> 最好的办法是用支持regexp的工具。 比如,grep,sed,awk,之类, >> >> echo $VAR|grep .*[kK][dD][eE].* 或许更能满足你的在求. >> >> >> >> _______________________________________________ >> >> Chinese mailing list >> >> Chinese at lists.fedoraproject.org >> >> https://admin.fedoraproject.org/mailman/listinfo/chinese >> >> >> > >> >_______________________________________________ >> >Chinese mailing list >> >Chinese at lists.fedoraproject.org >> >https://admin.fedoraproject.org/mailman/listinfo/chinese >> _______________________________________________ >> Chinese mailing list >> Chinese at lists.fedoraproject.org >> https://admin.fedoraproject.org/mailman/listinfo/chinese >           >_________________________________________________________________ >MSN十年回馈,每位用户可免费获得价值25元的卡巴斯基反病毒软件2010激活码,快来领取!>http://kaba.msn.com.cn/?k=1 >_______________________________________________ >Chinese mailing list >Chinese at lists.fedoraproject.org >https://admin.fedoraproject.org/mailman/listinfo/chinese
>_______________________________________________
>Chinese mailing list
>Chinese at lists.fedoraproject.org
>https://admin.fedoraproject.org/mailman/listinfo/chinese


关于邮件列表 Chinese 的更多信息