0

I want to search a directory's contents for a certain string on Ubuntu, and output all files that contain it. Problem: if zgrep tries to read a damaged file, the process stops:

zgrep -n 'test' /var/log/tomcat/archive/*

Result:

gzip: /var/log/tomcat/archive/my.log.gz: unexpected end of file

Question: how can I tell zgrep to ignore files that give errors?

terdon
  • 234,489
  • 66
  • 447
  • 667
membersound
  • 431
  • 1
  • 5
  • 17
  • What makes you say it stops? It shouldn't stop, are you sure it doesn't simply print the error and then continue to the next file? That's how it behaves on my system. – terdon Mar 21 '22 at 08:30
  • Are you sure it stops completely? In my tests, both `gzip`’s `zgrep` and `zutils`’ `zgrep` continue with the subsequent files. – Stephen Kitt Mar 21 '22 at 08:54

0 Answers0