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

Re: GREP



Colin Watson wrote:
> 
> Erik Steffl <steffl@bigfoot.com> wrote:
> >  calling grep just once is probably slightly more effective (even
> >though the grep stays in cache so it's not that much of a difference, I
> >guess)
> 
> Actually loading the program from disk or cache isn't the big hit, it's
> the fork/exec.
> 
> >  the main difference is a sideeffect, sort of, if grep is called for
> >with one file as an argument it only prints the line matched, not the
> >filename, so you get bunch of lines (each successfull match) but you
> >have no idea which files these lines are in...
> 
> grep -H ... this can be useful when using xargs too, as it's possible
> (though unlikely) that you overflow the number of parameters xargs can
> get onto one command line by one and thus end up with grep being called
> with one filename argument.

  yes, but -H does not seem to be 'well known' grep options (not all
grep implementation use it), it's not even on man page (none of the few
grep manpages we have here, one of them GNU), grep --help prints it out
though...

> 
> >  I can also use:
> >
> >  grep '[sf]printf' `find / -name '*.h' -print`
> >
> >  and probably some other more or less dirty tricks...
> 
> Eww. :) Evaluates the entire find before even starting the grep, and
> will just die with "Command line too long" if find comes up with too
> much ...

  that's what one gets for playing it dirty... I mentioned it mostly for
the curiosity value, it is (sort of) fun to figure out what are the
various ways one can accomplish given task...

	erik



Reply to: