4 ms·
99% of the time I use sed to mangle the output of a text file into something else. Earlier I did this cat as1 | grep " 65" | sed -e 's/.* 0 65/65/' -e 's/
by ta1243 2y ago
99% of the time I use sed to mangle the output of a text file into something else.
Earlier I did this
cat as1 | grep " 65" | sed -e 's/.* 0 65/65/' -e 's/[^ 0-9]//' |sort|uniq
Now some twat will come along and say my process should have been
cat as1
grep " 65" as1
grep " 65" as1 | sed -e (various different tries to the data looks useful)
grep " 65" as1 | sed -e (options) | sort|uniq
Because otherwise it's a "useless use of cat" and reformatting my line is well worth the time and cognitive load to save those extra forks.
- Etheryte 2y agoI think the concept of useless use of cat is one of the few things I strongly disagree with in software development. Most things have their trade-offs, pros and cons, but using cat to start a pipe makes everything composable and easy to work with, it's pretty much universally good. The moment you drop it because of the small redundancy, you have to make sure you don't mess up the params for whatever comes next, and that overhead is in my opinion never worth what you gain by dropping cat.
- deleted 2y ago[deleted]
- keybored 2y ago“Useless use of cat” is really “useless interjection and waste of a comment”.