Originally Posted by pixellany
One advantage of the way I wrote it could be readability for the beginner.
A real beginner does not know about pipes
, so the plain 'grep' is better in my view.
I ran a small test on a 200MByte text file. Don't know if it's really a reliable one:
time grep mytxt myfile
time cat myfile | grep mytxt
The commands were run a couple of times in random sequece (mixing both commands to 'eliminate' possible cache influences).
It surprised me that the 'cat' version actually was faster everytime it was executed. If other processes would have influenced the results, that would be equally true for both versions of the command.
PS: 'mytxt' only occured once as the first word on the last line
PS2: results are rounded