[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Grep problem
From: |
Stepan Kasal |
Subject: |
Re: Grep problem |
Date: |
Fri, 30 Sep 2005 11:40:30 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello.
> I want to exit after I find n matches in an input file. How can I do this?
you can program this easily with awk. Find a good book on the topic,
for example "Effective awk programming", or read the manual of GNU awk.
You mentioned "grep -m <n>". The -m option tells grep that it should exit
after <n> matching lines; if the line contains more matches it still counts
as one line. Note that this definition slightly differs from what you want
to achieve; if the distinction is important for you, you have to use awk.
Have a nice day,
Stepan Kasal