我正在遵循在如何在Linux上查找包含特定文本的所有文件?上的最佳答案来在我的项目中搜索字符串。
这是我的命令grep --include=*.rb -rnw . -e "pattern"
Zsh告诉我zsh:没有找到匹配项:--include=*.rb
看起来grep不支持--include
选项。
当我输入grep --help
时,它返回
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
这里不需要使用--include
。
是我的grep版本太旧了吗?还是我的命令出了问题?
grep 'pattern' -rIn '--include=*.{c*,h*}'
- linzuojiangrep
本身不理解这个符号表示法。请查看我的更新,其中显示了如何正确使用花括号扩展,并提供了一个包含背景信息的答案链接。 - mklement0