3 ms·
"grep <pattern> <files>" is not the same as "cat <files> | grep <pattern>", in that the former will prefix lines with filenames if there is more than one input
by omoikane 12y ago
"grep <pattern> <files>" is not the same as "cat <files> | grep <pattern>", in that the former will prefix lines with filenames if there is more than one input file. What you want instead is "grep -h <pattern> <files>".
The advantage of using cat, therefore, is the few seconds of laziness saved in not reading the manual.
- salgernon 12y agoThe advantage to using "cat foo | grep pattern" is that it is trivial to ^p and edit the pattern before adding the next pipeline sequence.
- philsnow 12y agofwiw $ <filename grep <pattern> no shell I'm aware of restricts you to placing redirections at the end, you can throw them on the beginning no problem.