3 ms·
If this a reference to "cat menu | grep shrimp | test -lt $10" there is more wrong with that than simply the senseless execution of the poor kitten in the proce
by UNIXgod 14y ago
If this a reference to "cat menu | grep shrimp | test -lt $10" there is more wrong with that than simply the senseless execution of the poor kitten in the processing of that statement.
It did follow with "though not syntactically correct". I believe the article was slated not for the current UNIX practitioners at the time but for communicating with NT administrators hence not following the concept where less external calls produces faster script execution; the referenced issue would have been `grep shrimp < menu` whereas the the redirection is optional as it's default.
None the less to be informative as the others which have responded I would like to expand on the concept as it's a logical pattern which is still passed down in explaining computational models and simply creating better development and scalable software where an interpreter is used.
Much like the current culture considers DRY( Don't Repeat Yourself) as a refactoring step to get their code to be the most bug free; fastest while being in form of a readable one-liner is much the same we do as stating "filter early and filter often".
Lighter weight tokens provide faster execution( i.e. use the utility command cut in place of the general purpose pipeline language awk; refactor to avoid unneeded call to xargs, and of course use cat only when it is useful such as testing heredocs prior to embedding the generator to log, mail, filesystem or network).
From my observations many people first begin to learn to use pipes with grep. First explanation is almost always to explore interactively the `cat file | grep pattern`. It's a poor pedagogy simply because it causes bad habits from the beginning.
We live in a autodidact world presently which is a good thing but the information on occasion seems to be diluted with a self starter which misinforms and creates a cancer growing within other sort of "what I learned on my OSX about this ancient UNIX thing" style posts.
We can't all have been lucky to read or learn from the philosophies of Kernighan, McIlroy et al. Though `cat` is a famous pet peeve (no pun intended) my personal favorite is when I read a post which explores regular expressions and claims that they came from grep or better I have actually seem someone claim that they came from perl. These are worse crimes than creating an award for executing kittens any day of the week.