我在当前目录中有一些目录,其名称类似“ mm-yyyy”(01-2014)。我想grep名称为“ 2013”的目录中的文件。如何排除名称不带“ 2013”的目录?我尝试了以下操作,但没有成功:
grep hill * -R --exclude-dir=*201[0-2]
它仍然遍历所有子目录来执行grep。
你可以用
grep -R hill *-2013
使用也--exclude-dir
应该工作:
grep -R hill --exclude-dir=".*201[0-2]" .
没有引号的星号将被bash扩展。此外,正则表达式的通配符为.*
. - matches any character
* - match any number of repetitions of the previous character, including none
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句