美文网首页
查找目录下包含特定字符串的文件

查找目录下包含特定字符串的文件

作者: 生信摆渡 | 来源:发表于2022-09-27 17:50 被阅读0次

需求

查找日志目录下空间超额的任务:

> find log -name *err | xargs grep 'Disk quota exceeded'
log/SRR8117383_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117375_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117368_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117367_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117367_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117364_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117382_download.err:cat: write error: Disk quota exceeded
log/SRR8117382_download.err:cat: write error: Disk quota exceeded
log/SRR8117446_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117384_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117362_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117380_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117413_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117396_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117370_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117421_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117378_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117393_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117393_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117373_download.err:gzip: stdout: Disk quota exceeded
log/SRR8117433_download.err:gzip: stdout: Disk quota exceeded
  • 删除错误的日志
find log -name *err | xargs grep 'Disk quota exceeded' | awk -F: '{print $1}' | uniq | xargs rm
  • 得到错误的任务号
find log -name *err | xargs grep '117407' | cut -b 5-14 | uniq

相关文章

网友评论

      本文标题:查找目录下包含特定字符串的文件

      本文链接:https://www.haomeiwen.com/subject/metqartx.html