find ./ -regex '.*\.\(cc\|h\|cpp\)'|xargs grep -P --color=auto -R -n '\bReAddAll'

-P  perl模式正则,无需字符转义

--color=auto  自动着色

-n  显示行号

 

grep -R "wangkangluo"  /var/www/html   //所有目录文件下查找字符串

 

比如,我想搜源码目录src下,包含“niuc”的所有ec文件

find ./src -name '*.ec' -exec grep -i niuc {} /; -print

 

在特定文件中grep某关键字,除了使用find 命令加exec选项之外,其实还有更简单的方法:

grep -R --include="*.cpp" key dir

上述命令的含义:

在dir目录下递归查找所有.cpp文件中的关键字key

 

是不是更简单呢?

相关文章:

  • 2021-09-07
  • 2021-08-17
  • 2022-12-23
  • 2022-02-03
  • 2021-11-20
  • 2021-11-20
  • 2021-05-26
  • 2021-09-19
猜你喜欢
  • 2021-11-27
  • 2021-11-02
  • 2021-07-01
  • 2022-01-02
  • 2021-05-17
  • 2022-12-23
  • 2021-09-01
相关资源
相似解决方案