Date: Wed, 6 Nov 2002 11:47:45 -0600 From: Dan Nelson <dnelson@allantgroup.com> To: Matthew Bettinger <mbettinger@championelevators.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: simple find command Message-ID: <20021106174745.GA96511@dan.emsphone.com> In-Reply-To: <200211061124.25334.mbettinger@championelevators.com> References: <200211061124.25334.mbettinger@championelevators.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021106174745.GA96511>