Live data from Hacker News

PSA about abuse of cat(1) command. Don't abuse cats

abuseofcats.com

61–62 of 62 posts

Re: PSA about abuse of cat(1) command. Don't abuse cats

#61
post #26

Earlier quoted context omitted.

I like piping the output of cat and the mental image of one process feeding another. It's inconsequential, but it brings an epsilon of joy.

same I just like monads lol. cat + pipe feels purer and has lower mental load for me, which dominates the efficiency of spawning an extra process for, typically, a few microseconds.

Exactly. It allows for a consistent pattern:

cmd1 | cmd2 | cmd3 | ... | cmdn

Re: PSA about abuse of cat(1) command. Don't abuse cats

#62
post #33

The beauty of cat is that streams are the universal interface. Program A might accept a file as the last positional arg. Program B might accept it as a named arg, where the name/flag could be anything from --input or -f or --file etc. But a program will read from STDIN, which all good unix programs do, then piping cat into it works every time. I can write the cat foo.txt part before I even know what command I'm pipin…

Yes, but "cat" is superfluous anyway. You can start your pipeline with a file redirection: " output_file".

My pipeline starts with displaying the file to stdout to make sure it's the correct file, and then building on from there, one new program call at a time. This is not a valid alternative.
Post reply on HN