Put down that pipe with cat 😺

I have to admit that I use cat with a pipe more then I should in shell scripting. Normally it’s not a terrible thing, though with big files, like the State Voter Database, it can be slow and wasteful of memory. In general, you should NOT use cat with program that can read file itself.

This is generally bad though it works most of the time:

cat file.txt | grep 'dog'

While this is much better:

grep 'dog' file.txt

Leave a Reply

Your email address will not be published. Required fields are marked *