bug#65416: Feature request: include first line of file in output

2023-08-23 Thread Daniel Green
Re Perl's read speed, it's faster when not doing the line number check for every line. So `perl -ne 'print if (/pattern/)'` is only ~2.60s, compared to ~3.28s for `perl -ne 'print if ($. == 1 || /pattern/)'`. Doing nothing in Perl, i.e., `perl -ne ''` is only ~1.38s. Dan On Wed, Aug 23, 2023 at 6

bug#65416: Feature request: include first line of file in output

2023-08-23 Thread Daniel Green
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 (

bug#65416: Feature request: include first line of file in output

2023-08-22 Thread Daniel Green
7;s faster. And it solves your problem NOW, > instead of waiting for a feature that the grep developers > aren't likely to add. > > My two cents of course. > > Arnold > > Daniel Green wrote: > > > That works, as well as the Perl version I've been using: > &

bug#65416: Feature request: include first line of file in output

2023-08-21 Thread Daniel Green
Admittedly grep is just searching in those timings, but I suspect it could accomplish the full task with a minimal decrease in speed. Dan On Mon, Aug 21, 2023 at 12:57 PM wrote: > Daniel Green wrote: > > > I'm frequently searching CSV files with 20-30 columns, and when there&#x

bug#65416: Feature request: include first line of file in output

2023-08-21 Thread Daniel Green
I'm frequently searching CSV files with 20-30 columns, and when there's a hit it can be hard to know what the columns are. An option to also print the first line of a file (either always, or only if that file had a match to the pattern) in addition to any hits would be nice. Thanks, Dan