Why ‘cat’ something and then pipe it into grep to search for something when grep can easily search a file/dir/wild card all by itself? It’s like taking your car to the dealership so you can change your own oil. What? No, that doesn’t really make any sense, but neither does piping cat into grep.
If you’re dealing with large files or complicated expressions, the reason you shouldn’t cat something into a pipe just to grep it becomes obviously clear.
# cd /var/log/httpd/
Lets look at some apache logs for example.
real 0m0.018s
user 0m0.0012s
sys 0m0.006s
real 0m0.009s
user 0m0.006s
sys 0m0.003s
The savings of a fraction of a second isn’t the point. It’s just a silly way to go about doing it. It’s not the end of the world, just plain old inefficient logic at work. Watching someone do this is almost as annoying as seeing them run “rm -rf” when they’re deleting a single file.
I just read a few posts on some forums where people complained about people that don’t like piping cat into grep, so I thought I’d feed the fire! :) Hopefully the time illustration shows you that catting huge logs really doesn’t matter anymore. Gotcha ibtch!
tl;dr? I was joking, I agree.
4:08 pm
Who the hell cares how other people (ab)use pipes?