4 ms·
I agree with you that `cat` is not really useless when it makes the code more readable, and the common idiom of `cat input-file | process | process | process >
by sltkr 3y ago
I agree with you that `cat` is not really useless when it makes the code more readable, and the common idiom of `cat input-file | process | process | process > output-file` can be more readable than `process <input-file | process | process > output-file`, while the theoretical performance overhead incurred by the needless cat is negligible in the majority of cases.
But for the sake of completeness I need to point out that technically I/O redirections can occur anywhere in the command line, so if you want to maintain left-to-right reading order, you can do that without resorting to cat, by writing:
<input-file process | process | process >output-file
For example:
</etc/passwd awk -v FS=: '{ print $7 }'
Works just as well as the more idiomatic:
awk -v FS=: '{ print $7 }' /etc/passwd