This is probably in many FAQs - instead of using:
cat file | command
(which is called useless use of cat), correct way supposed to be:
command < file
In the 2nd, "correct" way - OS does not have to spawn an extra process.
Despite knowing that, I continued to use useless cat for 2 reasons.
more aesthetic - I like when data moves uniformly only from left to right. And it easier to replace
catwith something else (gzcat,echo, ...), add a 2nd file or insert new filter (pv,mbuffer,grep...).I "felt" that it might be faster in some cases. Faster because there are 2 processes, 1st (
cat) does the reading and the second does whatever. And they can run in parallel, which means sometimes faster execution.
Is my logic correct (for 2nd reason)?