【发布时间】:2016-01-13 20:12:04
【问题描述】:
我有一个目录,还有数千个其他目录,每个目录都包含一致的目录结构以及我想用 grep 查找文本模式的特定文件名。
假设我从我的根目录中启动 grep,目录如下:
/
/dir1
/etc
/net
/file.properties
/dir2
/etc
/net
/file.properties
我想在所有目录 dir1、dir2 等中搜索位于路径“*/etc/net/file.properties”下的所有 file.properties 文件中的文本模式
在我指定的路径结构下,在 file.properties 中搜索所有 dir1、dir2...dirN 的模式时,我的 grep 命令会是什么样子?
我现在拥有的是:
grep -r "text here" --include='*/net/etc/file.properties' .
【问题讨论】:
-
你必须只使用 grep 吗?你不能找到所有 file.properties 文件,然后从该结果集中 grep 吗?
标签: search terminal grep directory pattern-matching