Hacker News new | past | comments | ask | show | jobs | submit login

"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.




The advantage to using "cat foo | grep pattern" is that it is trivial to ^p and edit the pattern before adding the next pipeline sequence.


fwiw

    $ <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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: