grep 多个扩展当前文件夹和子文件夹

标签 grep

我正在尝试 grep 当前文件夹和所有子文件夹中的多个扩展名。

grep -i -r -n 'hello' somepath/*.{php,html}

这只是 grep 当前文件夹,而不是子文件夹。

这样做的好方法是什么?

最佳答案

仅使用 grep:

grep -irn --include='*.php' --include='*.html' 'hello' somepath/

关于grep 多个扩展当前文件夹和子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1639985/

相关文章:

bash - 您如何通过 grep 将输入管道传输到另一个实用程序?

grep - 使用 grep 匹配时搜索字符串中存在空格。

linux - 创建一个 oneliner 来导入数据库

linux - 如何从下载的网页中提取信息?

regex - 在 grep 中抑制匹配本身

unix - 如何 grep 查找整个单词

regex - 使用 grep 分割字符串的 shell 脚本

regex - Grep 获取单行注释,但排除 http ://example. com 等内容

bash - 使用 Bash 获取最后一次出现的正则表达式模式匹配

linux - 如何使用 AWK regExp 在不同列中以 Excel 格式打印多个子字符串模式