GNU bug report logs -
#65416
Feature request: include first line of file in output
Previous Next
Reported by: Daniel Green <ddgreen <at> gmail.com>
Date: Mon, 21 Aug 2023 07:16:02 UTC
Severity: wishlist
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #35 received at 65416 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 <pj <at> usa.net> wrote:
> oops - grep slower than awk, not the other way around,
> on these _highly_ inconclusive timings.
>
> --
> Paul Jackson
> pj <at> usa.net
>
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 321 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.