当我尝试使用locate
和进行搜索时,grep
例如:
locate A-B | grep .dir
结果是:
.../A-B-C.dir
.../A-B-C.dir/file
.../A-B-C.dir/file1
.../A-B-D.dir
.../A-B-D.dir/file1
...
如何修改grep
或locate
使搜索结束.dir
?
我的系统很旧:
安全定位2.7-2003年1月24日发布
grep(GNU grep)2.5.1
如果这是Linux系统,则可能locate
支持正则表达式:
locate --regex 'A-B.*\.dir$'
如果不,
locate 'A-B' | grep '\.dir$'
要点是使用正确将正则表达式锚定到行的末尾$
。
请注意,这两个变体都可以找到例如/some/path/ABBA-Bootlegs/thing.dir
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句