Date: Wed, 6 Nov 2002 17:49:57 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-questions@FreeBSD.ORG Subject: Re: simple find command Message-ID: <20021106174957.GA25190@happy-idiot-talk.infracaninophi> In-Reply-To: <200211061124.25334.mbettinger@championelevators.com> References: <200211061124.25334.mbettinger@championelevators.com>
index | next in thread | previous in thread | raw e-mail
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021106174957.GA25190>
