要求:
在Dir目录及其子目录下的所有的"*.py"文件中搜索字符串“xxx”
1. 首先使用find命令找出所有的"*.c"文件,然后使用grep命令查找:
find Dir -name "*.py" | xargs grep xxx
2. 使用grep命令的--include选项
--include=GLOB
Search only files whose base name matches GLOB (using wildcard
matching as described under --exclude).
grep -r --include="*.py" "xxx" Dir