#!/bin/bash
find . -iname \*.[ch] -exec grep --color -wn -H $1 \{\} \;
find . -iname \*.cpp -exec grep --color -wn -H $1 \{\} \;
总结一下语法就是:
find $搜索目录 -iname \*.cpp -exec grep --color -wn -H $1 \{\} \;
本文介绍了一个使用Bash脚本进行C/C++源代码搜索的方法,并通过grep命令实现搜索词的高亮显示。该脚本能够帮助开发者快速定位到指定字符串在C/C++文件中的位置。
#!/bin/bash
find . -iname \*.[ch] -exec grep --color -wn -H $1 \{\} \;
find . -iname \*.cpp -exec grep --color -wn -H $1 \{\} \;
总结一下语法就是:
find $搜索目录 -iname \*.cpp -exec grep --color -wn -H $1 \{\} \;
7589

被折叠的 条评论
为什么被折叠?