From owner-freebsd-questions Wed Nov 6 13: 6:42 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBDA537B401 for ; Wed, 6 Nov 2002 13:06:40 -0800 (PST) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4349743E4A for ; Wed, 6 Nov 2002 13:06:40 -0800 (PST) (envelope-from swear@attbi.com) Received: from localhost.localdomain ([12.242.158.67]) by sccrmhc01.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20021106210639.GLH25908.sccrmhc01.attbi.com@localhost.localdomain>; Wed, 6 Nov 2002 21:06:39 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost.localdomain (8.12.6/8.12.5) with ESMTP id gA6L7EUW011440; Wed, 6 Nov 2002 13:07:15 -0800 (PST) (envelope-from swear@attbi.com) Received: (from jojo@localhost) by localhost.localdomain (8.12.6/8.12.5/Submit) id gA6L73H4011437; Wed, 6 Nov 2002 13:07:03 -0800 (PST) (envelope-from swear@attbi.com) X-Authentication-Warning: localhost.localdomain: jojo set sender to swear@attbi.com using -f To: mbettinger@championelevators.com Cc: Subject: Re: simple find command References: <200211061124.25334.mbettinger@championelevators.com> From: swear@attbi.com (Gary W. Swearingen) Date: 06 Nov 2002 13:07:03 -0800 In-Reply-To: <200211061124.25334.mbettinger@championelevators.com> Message-ID: <3avg3ao1ag.g3a@localhost.localdomain> Lines: 18 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Matthew Bettinger writes: > I have a list of files (hundreds) in directory . and need to search through > and delete every file that contains the word foo. Assuming that "directory" means "directory tree" and that "word" means "string", this might work: find . -type f -print0 | xargs -0 grep --null -l foo | xargs -0 rm -f Test this or whatever you use thoroughly; such things are likely to delete things you don't want deleted and/or not delete things you you want deleted. You're likely to want additional options on "rm", like maybe "-P". Use the man pages to know what you are doing and can do -- and test things well using test directories, etc. If you really meant "word foo", then you've got a much tougher job, starting with defining "word". See the grep manual, at least. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message