bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep patch


From: Stepan Koltsov
Subject: Re: grep patch
Date: Fri, 18 Jan 2002 14:48:19 +0300
User-agent: Mutt/1.3.25i

On Thu, Jan 17, 2002 at 03:47:08PM -0800, Paul Eggert wrote:
> > > grep -h pattern | sed "s,^,$fn:,"
> > 
> > It works bad when I use grep with options such as -C
> 
> I don't see why.

grep -C1 pattern

prints

file-lalala
file:anywhere in line there is pattern
file-lalalalala
--
file-lalalalala
...

with sed it will be:

file:lalala
file:anythere in line there is pattern
file:lalalalala
file:--
file:...

First is better.

> > > grep -r is used often enough that it's reasonable to have as an
> > > option, both for convenience and performance.
> > 
> > This options used often because grep has it.
> 
> No, you've got it backwards.  grep didn't have -r for many years, but
> many ordinary users kept asking for it, so it got added to grep.  As
> far as I know you are the only one who's ever asked for anything like
> --fake-filename.

You should answer them -- use find. grep with option -r cannot do a lot
of things, that find + grep can, for instance, I often do something
like:
find . -name '*.h' | xargs grep -w uint32_t

find intended for finding files, grep -- for grepping them :-)

-- 
mailto:address@hidden
irc.openprojects.net/#debian-russian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]