如果文件夹下存在如下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的定义。