3 ms·
> 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 th
by ilyt 4y 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
- benatkin 4y agoThat's a lot of extra processes! There's also zgrep: https://man.openbsd.org/OpenBSD-5.9/grep.1 https://man.openbsd.org/OpenBSD-5.9/grep.1
- scubbo 4y agoAnd if you're in a situation where you care about the overhead of extra processes, you wouldn't be exploratively and iteratively constructing a query on the command-line - you'd have already done the exploration in order to understand exactly what query you needed, and then would be converting the query into a non-bash programming language for optimization.