From owner-freebsd-questions Sat Jan 19 3: 1:39 2002 Delivered-To: freebsd-questions@freebsd.org Received: from relay3-gui.server.ntli.net (relay3-gui.server.ntli.net [194.168.4.200]) by hub.freebsd.org (Postfix) with ESMTP id A8CC737B405 for ; Sat, 19 Jan 2002 03:01:32 -0800 (PST) Received: from pc3-card4-0-cust122.cdf.cable.ntl.com ([62.254.251.122] helo=rhadamanth.private.submonkey.net ident=exim) by relay3-gui.server.ntli.net with esmtp (Exim 3.03 #2) id 16RtFb-00060P-00; Sat, 19 Jan 2002 11:01:31 +0000 Received: from setantae by rhadamanth.private.submonkey.net with local (Exim 3.34 #1) id 16RtFA-000349-00; Sat, 19 Jan 2002 11:01:04 +0000 Date: Sat, 19 Jan 2002 11:01:04 +0000 From: Ceri To: "J. S." Cc: freebsd-questions@freebsd.org Subject: Re: How to delete only empty directories Message-ID: <20020119110104.GC11503@rhadamanth> Mail-Followup-To: Ceri , "J. S." , freebsd-questions@freebsd.org References: <20020119111746.7fea5191.johann@broadpark.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020119111746.7fea5191.johann@broadpark.no> User-Agent: Mutt/1.3.25i 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 On Sat, Jan 19, 2002 at 11:17:46AM +0100, J. S. wrote: > > Now I need to delete those empty directories and _only_ the empty > directories. Does anyone know how? > > I did a "find ./ -type d -empty > ../empties" to at least get control over > what I need to remove. But it is like several hundred directories and I > ain't planning on doing it all manually =) If you're sure that find ./ -type d -empty is giving you the correct list of what you want to delete, use this : find ./ -type d -empty -exec rmdir {} \; If you're not sure (and I would recommend running this initially anyway to make sure it's deleting what you think) : find ./ -type d -empty -ok rmdir {} \; which will ask for confirmation before doing anything. Ceri -- keep a mild groove on To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message