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

Re: GREP



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.

>  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 ...

-- 
Colin Watson                                     [cjw44@flatline.org.uk]



Reply to: