Controversial opinion:

A "cat" can only be useless in scripts, not in the direct tty.

Because more often than not, it saves you time as you dynamically adjust your command.

Who always knows which 2nd command supports reading a file via argument? And even remembers the argument name?

I think even in scripts its fine to use cat, it often makes it more clear what you're doing.

Follow

@Anachron
In some cases letting the program read the file directly instead of spawning cat and piping its output is preferrable, but in most cases it would be precipitate optimization — always a mistake, clarity is more important. That's a valid point indeed!
We're talking shell scripts here, any optimization in absolute most cases would be ephemeral… Unless it's something like using [START..END] sequence to pass thousands of filenames as parameters instead of using a proper loop of course 🤭

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml