按部分内容查找文件

Chr*_*vic 4 search recursive files

我在一个特定的存储库中有很多文件,我必须找到一个在其内容中包含特定字符串的文件(实际上是引用文件Version.cc.in)。找到它的最佳解决方案是什么?

pbm*_*pbm 5

您可以使用 grep:

grep "text" /path/to/directory/*
Run Code Online (Sandbox Code Playgroud)

对于递归搜索,您可以使用-rgrep 选项:

grep -r "text" /path/to/directory/*
Run Code Online (Sandbox Code Playgroud)

**在路径中:

grep "text" /path/to/directory/**/*
Run Code Online (Sandbox Code Playgroud)

但是,**运算符的可用性取决于外壳程序-据我所知,它在zshbash(仅 4 个?)中,在其他外壳程序中可能不可用。

  • @ChristianIvicevic 或者你可以运行`grep -r "text" /path/to/directory`。 (5认同)