Useless Use of Cat
Debate on the 'Useless Use of Cat' (UUOC) in Unix shell pipelines, weighing readability and left-to-right data flow benefits against the inefficiency of spawning extra processes compared to input redirection or direct file arguments.
Activity Over Time
Top Contributors
Keywords
Sample Comments
People like cat because it allows notating the command closer to how they think. How can I pipe while putting the file first?
Surely using cat like this is more in line with the unix philosophy?
It's one more process to run, so `cat single_file | ` can be easily substituted with `<single_file `.
How many people actually use shell redirection to copy and filter a file?
People use cat to look at the file first, then hit up arrow, add a pipe, etc.
The ` < file` has to appear at/near the end of the line, right? Using cat has the advantage of being able to read the line from left to right along with the data flow. I often add more piped commands to the end of a line as I refine it, while the source data remains the same. (To be fair, sometimes the opposite is true.)
Hm. Why not re-use "tee"?https://www.man7.org/linux/man-pages/man1/tee.1.html
If only we could do `fileA> command >fileb` for the ultimate readability...
Cat is awesome :) There is also 'tac' (reverse of cat) installed on most systems
"| cat" has this effect.