I'm looking for the string foo=
in text files in a directory tree.
(我在目录树中的文本文件中寻找字符串foo=
。)
It's on a common Linux machine, I have bash shell: (它在一台普通的Linux机器上,我有bash shell:)
grep -ircl "foo=" *
In the directories are also many binary files which match "foo=".
(在目录中还有许多匹配“foo =”的二进制文件。)
As these results are not relevant and slow down the search, I want grep to skip searching these files (mostly JPEG and PNG images). (由于这些结果不相关并且减慢了搜索速度,我希望grep跳过搜索这些文件(主要是JPEG和PNG图像)。)
How would I do that? (我该怎么办?)
I know there are the --exclude=PATTERN
and --include=PATTERN
options, but what is the pattern format?
(我知道有--exclude=PATTERN
和--include=PATTERN
选项,但模式格式是什么?)
The man page of grep says: (grep的手册页说:)
--include=PATTERN Recurse in directories only searching file matching PATTERN.
--exclude=PATTERN Recurse in directories skip file matching PATTERN.
Searching on grep include , grep include exclude , grep exclude and variants did not find anything relevant
(搜索grep include , grep include exclude , grep exclude和variants没有找到任何相关内容)
If there's a better way of grepping only in certain files, I'm all for it;
(如果有一种更好的方法只在某些文件中进行grepping,我就是全力以赴;)
moving the offending files is not an option. (移动违规文件不是一种选择。)
I can't search only certain directories (the directory structure is a big mess, with everything everywhere). (我不能只搜索某些目录(目录结构很乱,随处可见)。)
Also, I can't install anything, so I have to do with common tools (like grep or the suggested find ). (另外,我无法安装任何东西,所以我必须使用常用工具(如grep或建议的查找 )。)
ask by Piskvor translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…