Very nice article. Refreshing to see one liners and fun projects. And the website’s glamour mode is great, too.
Although, as tradition requests, any example of the useless use of `cat` (UUOC) must be called out. The _much_ more efficient use would of course be
tr '\n' ' ' < input.txt | tr -d '\r' | fold …How is avoiding a single invocation of cat much more efficient?
I feel if anything needs calling out, it's mistaking opinions for universal laws.
> tr '\n' ' ' < input.txt | tr -d '\r' | fold …
I enjoy discovering and decrypting these one liners much more than reading about what someone's AI agent generated recently.
These uses of cat aren't useless.
It improves readability. One reads shell commands from left to right, following the logic of each step in the pipeline individually. It makes sense to start with a file, then pipe that to command 1, pipe that to command 2, etc. It makes less sense to start with command 1 into which we put the file and then take the output of command 1 from before the file and put that into command 2 etc.
It also improves future editability. If you wanted to change the input to command 1, you go tweak the bit to the left of command 1 instead of having to hunt down where the < is stuck in the middle somewhere and potentially remove it and replace it with something off to the left anyway depending on whether it's a file or the output of some other command.
Using cat as the first step into a pipeline is almost always the right thing to do!