On Wed, Jun 24, 2020 at 12:33:19PM +0200, Albretch Mueller wrote:
> > "grep -l" will stop at the first hit, so even if you could ask
> > grep which one of the alternatives it found, it'll miss Hegel
> > in a file where Kant figures first. Is that what you want?
> 
>  Yes, I am fine with that. I include the matches in the Array in a way
> that the first one is the most important to me anyway, but I need to
> know which one, which I think should be someone possible, since grep
> must go through the array using some index, no?

OK, if you just want the first hit, there is "--max-count" (aka "-m"),
which you can use with the combined regular expression. This (given
the value 1) will spit out the first matching line, which you can
then post-process to extract the exact match.

Post-processing is left as an exercise to the reader :-)

That should be about as fast as "grep -l" can get, take or give.

Cheers
-- tomás

Attachment: signature.asc
Description: Digital signature

Reply via email to