[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep: print one match switch
From: |
Jim Meyering |
Subject: |
Re: grep: print one match switch |
Date: |
Sun, 21 Oct 2001 09:09:01 +0200 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.0.107 |
Dan Jacobson <address@hidden> wrote:
> If grep has these features
>
> -L, --files-without-match
> Suppress normal output; instead print the name of
> each input file from which no output would normally
> have been printed. The scanning will stop on the
> first match.
>
> -l, --files-with-matches
> Suppress normal output; instead print the name of
> each input file from which output would normally
> have been printed. The scanning will stop on the
> first match.
>
> Then how could it be that it lacks a switch to just print one match,
> equivalent to awk '/pattern/{print;exit}'.
Maybe you just need a newer version?
$ grep --help |grep max-count
-m, --max-count=NUM stop after NUM matches
$ grep --version
grep (GNU grep) 2.5e
...
$ seq 30 |grep --max-count=2 4
4
14