在文件系统的某一个目录中查找某一个字符串

在文件系统的某一个目录中查找某一个字符串
举例:
for file in `find /app/tpssapp/data -type f`; do find_flag=`grep -n 1330208381 $file`; if [ ${#find_flag} -gt 0 ]; then echo $file; echo $find_flag; fi done;
这个语句实际上是个shell脚本,比较复杂些。

find /app/tpssapp/data -type f -exec grep -n 1330208381 {} \;
这个语句不能显示出文件名称。

find /app/tpssapp/data -type f | xargs grep -n 1330208381
这个语句应该是最值得推荐的了。

猜你喜欢

转载自www.cnblogs.com/babyha/p/9507038.html