Grep can accept input from stdin as with a piped cat, but I it can also just call the file directly.
In 99.999% obviouslymadeupstatisobvious of situations its fine.
The real issue is a piped cat into grep will fork the process. Why open two process threads when one would do the job?
Edit: it was mentioned by but to expand a bit: piping cat into grep can also mask quite a few errors. It masks them because of how the shell handles error reporting on piped processes. IIRC, if the file is missing for example, you won’t necessarily know that because while cat will throw a not-found error, that gets piped into grep who gladly accepts the error (which was piped to stdin) as its input and greps through the error, reporting back that your content wasn’t found in the search material, not that the file was missing.
cat sends its error via stderr so it won’t go into the pipe (or grep). you will see the cat error on your terminal, unless you have redirected stderr to stdout
Grep can accept input from stdin as with a piped cat, but I it can also just call the file directly.
In 99.999% obviously made up stat is obvious of situations its fine.
The real issue is a piped cat into grep will fork the process. Why open two process threads when one would do the job?
Edit: it was mentioned by
but to expand a bit: piping cat into grep can also mask quite a few errors. It masks them because of how the shell handles error reporting on piped processes. IIRC, if the file is missing for example, you won’t necessarily know that because while cat will throw a not-found error, that gets piped into grep who gladly accepts the error (which was piped to stdin) as its input and greps through the error, reporting back that your content wasn’t found in the search material, not that the file was missing.
cat sends its error via stderr so it won’t go into the pipe (or grep). you will see the cat error on your terminal, unless you have redirected stderr to stdout
What the fork is this forking shirt?
Soz I read your comment as if it were from the good place.