脚本 #!/bin/bash for file in $1/*.h do timespec=`strings $file | grep "struct timespec {"` if [ -n "$timespec" ]; then echo $file # echo $file: $timespec fi done 执行 搜索 /home/guol 下所有包含 struct timespec { 的头文件:sh iterate.sh /home/guol