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

Devil Wang wxjeacen在gmail.com
星期二 四月 20 04:17:29 UTC 2010


*
*你难道不知道什么是grep吗??


2010/4/20 LI Rui Bin <cheeseli在hotmail.com>

> 我这个命令有问题,如果$VAR本来是null的,我这样测试也会返回0
> On 04/20/2010 01:04 AM, LI Rui Bin wrote:
> > 翻了一下书
> > 也可以 test -z ${VAR##*kde*}
> > On 04/20/2010 12:33 AM, Chen Lei wrote:
> >
> >> echo $VAR|grep -q kde
> >>
> >>
> >>
> >>
> >> 在2010-04-20 00:26:37,"LI Rui Bin"<cheeseli在hotmail.com>   写道:
> >>
> >>
> >>> 我要在bash里测试一个字符串是否包含某个子串,该怎么写?比如测试 $VAR 中是
> >>> 否含有 "kde" 字样
> >>> _______________________________________________
> >>> 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
> >
>
> _______________________________________________
> Chinese mailing list
> Chinese at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/chinese
>



-- 
Thanks & Regards

Linux Developer : Devil Wang


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