On Wed, Nov 06, 2002 at 11:24:19AM -0600, Matthew Bettinger 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

    find . -type f -print | xargs grep -l foo | xargs rm

or if you have file names with spaces or other characters
syntactically significant to the shell:

    find . -type f -print0 | xargs -0 grep -l --null foo | xargs -0 rm

        Cheers,

        Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
                                                      Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to