↑ ↓ select, Enter open, Esc close

Search rotated and compressed logs too

Adjust the values, the command updates live
root@server
zgrep -h "Out of memory" /var/log/syslog*

zgrep works like grep but automatically decompresses .gz files and reads normal files as they are. The * at the end covers the current file, .1 and all .gz archives. -h omits the file name before each matching line; without that option you can see which rotation a match comes from.

Note: The files are processed in alphabetical order, not chronologically. Sort the output afterwards if you need a time-based order.

Also searched as

  • search old gz logs
  • grep compressed log files
  • grep in rotated logs
  • search last week's logs

Related one-liners

All in Logs

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.