grep应用实例

如果文件夹下存在如下file:

qapatch_Hspice.sp
qapatch_SmartSpice.sp

aaa.sp

spiceout.err
spiceout.log

当使用如下规则查找结果时要注意:command line的meta字符和grep的meta字符是不一样的定义。

command line中*表示任意字符,而grep的meta字符表示重复前个字符0到多次。

1.

ls | grep '.*/.sp'

得到结果:

qapatch_Hspice.sp
qapatch_SmartSpice.sp

aaa.sp

 

2.

 ls | grep '.*sp'

得到结果:

qapatch_SmartSpice.sp

aaa.sp

spiceout.err
spiceout.log

 

3.

ls | grep '*sp'

得到结果:

 

4.

如果不用ls,则grep将在

qapatch_Hspice.sp
qapatch_SmartSpice.sp

aaa.sp

spiceout.err
spiceout.log

中去查找相对应的行是否符合pattern的定义。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值