logoalt Hacker News

hn_throwaway_99today at 3:26 AM1 replyview on HN

Yeah, I read TFA, and my eyes were rolling the whole time. Some people really have a bee in their bonnet that "cat" is named that way because it was originally for concatenating files. Nobody fucking cares. It's the standard way for writing a file to standard out, and the general pattern of "cat file.txt | somecommand | othercommand | anothercommand" is so useful because it follows the pipeline pattern so well - read from standard in, write to standard out - that is the cornerstone of Unix shell commands IMO.

"Oh no, it spawns another process!!" Again, nobody cares.


Replies

adrian_btoday at 4:37 AM

The simpler and better way to write your pipeline is:

"< file.txt somecommand | othercommand | anothercommand"

There is never any need for "cat".

When such a pipeline is used repeatedly in a script, the time for executing the redundant process "cat" can easily add up to a noticeable delay.