On the original test machine I timed the sed solution, as well as `(grep -m1 . 'file' && grep 'pattern' 'file')` and `(mapfile -n1 <'file' && echo $MAPFILE[0] && grep 'pattern' 'file')` and `(head -n1 'file' && grep 'pattern' 'file')`. Total table of speeds.
grep (v2.20): ~1.15s perl (v5.36.1): ~4.48s awk (v4.0.2): ~10.81s sed (v4.2.2): ~8.15s grep && grep: ~1.15s mapfile && grep: ~1.15s head && grep: ~1.15s I can write a shell function to make the head+grep version a little easier to use in practice (i.e., loop over the list of files passed calling head+grep on each one instead of calling head on the list and then grep on the list), but I believe it would be difficult to change any options given to grep. I still think the best combination of speed + output as I imagine + ease of integrating with changing grep options used is accomplished by a new option for grep. But if there's no interest then this feature request can be closed. Dan On Wed, Aug 23, 2023 at 4:23 AM Paul Jackson <p...@usa.net> wrote: > oops - grep slower than awk, not the other way around, > on these _highly_ inconclusive timings. > > -- > Paul Jackson > p...@usa.net >