Re: [PATCH/RFC 0/4] grep: support to match by line number
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- May 2, 2011, 17:11 UTC
- Message-ID
- <m31v0hvxi3.fsf@localhost.localdomain>
- In-Reply-To
- <7vfwoxoy5c.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> I am personally not thrilled by what this series attempts to do, but first > a few questions: > > - Are there existing non-git "grep" implementations that do this? > > - If yes: > - what command option letter do they use to specify line number? > - do they not support a range notation (e.g. -@ 25-30,32-40)? > - what do they do when given more than one file?
I'm not sure if it is exactly the same as '-@' in Bert proposal, but "ack", grep-like text finder in Perl (http://betterthangrep.com or http://p3rl.org/ack), includes the following command line option:
--line=NUM
Only print line NUM of each file. Multiple lines can be given with
multiple --line options or as a comma separated list
(--line=3,5,7). --line=4-7 also works. The lines are always output in
ascending order, no matter the order given on the command line.-- Jakub Narebski Poland ShadeHawk on #git