In the last episode (Nov 06), Matthew Bettinger said:
> 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

How about something like

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

which will pipe a list of all files into "xargs grep", which will then
output only the filenames that have foo in them, which gets piped into
"xargs rm" which removes them.

-- 
        Dan Nelson
        [EMAIL PROTECTED]

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

Reply via email to