find in conjuction with grep
Kevin Wang
rightsock at gmail.com
Thu Aug 12 21:51:42 UTC 2004
two issues - security and performance. performance was covered
already. explicitly, xargs can be 100x or more faster.
The security issue I don't remember being explicitly covered.
find . -exec grep "string" {}
what happens when you have a filename with a space in it?
quotes?
double quotes?
xargs suffers from the same issues, that's why there's the -print0 arg
for find and -0 arg for xargs - \0 terminated strings are guaranteed,
as nulls are one of the only invalid filename characters.
sure, 99% of the time it isn't a problem, but when you're writing
scripts that run as root that are running on a multi user system
(think thousands of college students with too much time on their hands
just wanting to break in and read everyone else's email)
- Kevin
On Thu, 12 Aug 2004 22:10:37 +0200, Alexander Dalloz
<alexander.dalloz at uni-bielefeld.de> wrote:
> Am Do, den 12.08.2004 schrieb Lew Bloch um 21:08:
>
> > >>I've been using
> > >>> find . -exec grep "phrase I want" {} \;
> > >
> > > Not the best way. Using -exec is problematic.
> >
> > How exactly is the -exec directive problematic?
> >
> > I use "find ... -exec grep ..." a lot. I also use the "find ... | xargs
> > grep ..." a lot.
>
> Please see the thread discussion. It is already answered.
>
> Alexander
>
> --
> Alexander Dalloz | Enger, Germany | GPG key 1024D/ED695653 1999-07-13
> Fedora GNU/Linux Core 2 (Tettnang) kernel 2.6.7-1.494.2.2smp
> Serendipity 22:09:55 up 8 days, 15:37, load average: 1.27, 1.23, 1.27
>
>
>
More information about the fedora-list
mailing list