GNU bug report logs -
#28304
Feature Request - Quit on Non Match
Previous Next
Full log
View this message in rfc822 format
Adam Danischewski <adam.danischewski <at> gmail.com> wrote:
> I've been writing parsers and it would be really nice if grep could do the
> following:
>
> *grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)*
>
> If you:
> *grep -m 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)*
>
> Only the first match of the header block gets printed, yet it would be nice
> if grep in O(n), could simply be on the look out for the first failure to
> match the -o context and quit at --quit-nm non-match occurrences.
I may be misunderstanding what you want, but something like
awk '/pattern to match/ { print ; continue }
{ exit 0}' file
might do what I think you want - exit on first non match.
If gawk can do the same matching you're doing with grep -Pno, that
is a different question.
HTH,
Arnold
This bug report was last modified 7 years and 293 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.