首页 > 其他 > 详细

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

时间:2018-08-20 18:31:32      阅读:292      评论:0      收藏:0      [点我收藏+]

在文件系统的某一个目录中查找某一个字符串
举例:
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
这个语句应该是最值得推荐的了。

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

原文:https://www.cnblogs.com/babyha/p/9507038.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!