|
|
|
|
|
by ilyt
1200 days ago
|
|
> What's natural about cat on only one file? It's about building the query, really. Here is example: cat file.log
"Oh, it's too big, I only care about these messages" cat file.log |grep error_name
"don't care about old stuff, show me the new one" cat file.log |grep error_name | tail
"hmm, show me when it started, and let's ignore monitoring checks" cat file.log |grep error_name | grep -v 'user: mon'| head
"okay, but maybe log was rotated ? Let's see last week" zcat file.log.1 |grep error_name | grep -v 'user: mon'| head
"hmm, it's some old error, let's search some more logs" zcat file.log.{10..1} |grep error_name | grep -v 'user: mon'| head
(zcat will auto add .gz if not passed)You can't for example do < file.log.{1..10} zcat
|
|
There's also zgrep: https://man.openbsd.org/OpenBSD-5.9/grep.1