I noticed that the sed version was much faster than the grep hack I tried ( all those pipes!) but I didn't time it.
All things considered, I award "awk" the prize of "most elegant" for its 3 less characters in the command string and slight performance edge!
Thanks guys!
John
On Wed, Nov 10, 2010 at 11:56 AM, Sean Walberg sean@ertw.com wrote:
Adam and I were having an offline discussion, and some testing shows that AWK outperforms SED by a slight margin: [sean@bob tmp]$ W=/usr/share/dict/words [sean@bob tmp]$ (tail -1000 $W; echo output start; cat $W; echo output end; head -1000 $W) > infile [sean@bob tmp]$ wc -l infile 481831 infile [sean@bob tmp]$ time awk '/output start/,/output end/' < infile > /dev/null real 0m0.411s user 0m0.393s sys 0m0.016s [sean@bob tmp]$ time sed -n '/output start/,/output end/p' < infile > /dev/null real 0m0.678s user 0m0.631s sys 0m0.029s I ran it a bunch more times and the results were similar. YMMV, benchmarks are lies, etc. Sean On Wed, Nov 10, 2010 at 11:32 AM, Gilles Detillieux grdetil@scrc.umanitoba.ca wrote: