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 #29 received at 65416 <at> debbugs.gnu.org (full text, mbox):
sed and awk can also to this (1st line plus any matching lines)
Following transcript from zsh session on my fast Ryzen:
$ <<-'@@' time sh -c "grep -m1 USER && grep carenas"
USER,TIP
john,0
jane,10
carenas,100
@@
USER,TIP
carenas,100
sh -c "grep -m1 USER && grep carenas" 0.00s user 0.00s system 93% cpu 0.003 total
$ <<-'@@' time sed -n -e 1p -e /carenas/p
USER,TIP
john,0
jane,10
carenas,100
@@
USER,TIP
carenas,100
sed -n -e 1p -e /carenas/p 0.00s user 0.00s system 80% cpu 0.001 total
$ <<-'@@' time awk 'NR == 1 || /carenas/'
USER,TIP
john,0
jane,10
carenas,100
@@
USER,TIP
carenas,100
awk 'NR == 1 || /carenas/' 0.00s user 0.00s system 88% cpu 0.002 total
As I expected, sed is fastest, grep next, and awk slowest of the three,
but the 1, 2, and 3 millisecond totals are within the margin of test error.
--
Paul Jackson
pj <at> usa.net
This bug report was last modified 1 year and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.