On Wed, Nov 06, 2002 at 11:24:19AM -0600 Matthew Bettinger 
<[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I am having a bit of trouble with the find command.  I am a novice in its use 
> so maybe someone can help  me out here. 
> 
> I have a list of files (hundreds) in directory . and need to search through 
> and delete every file that contains the word foo.
> 
> Some of my failed attemps...
> 
> find . -exec grep -i "foo" -ok -delete {} \;
> 
> find . -exec grep -l 'foo' -ok -delete {}\;
> 
> find . -exec grep "foo" {}\; | xargs rm

well, you've gotten some fine find advice, so I'll just suggest
that you don't have to use find:

bash]$  grep -H foo * | cut -d: -f1 | while read file; do
 > echo deleting $file && rm $file
 > done

You've already seen how to do it with xargs; this is just another
possibility that happens to work even when the filename has
metacharacters in it. 

-- 
David S. Jackson                        [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I think we're all Bozos on this bus.
                -- Firesign Theatre

Attachment: msg08526/pgp00000.pgp
Description: PGP signature

Reply via email to