From owner-freebsd-questions Sat Jan 19 8:50:13 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail7.nc.rr.com (fe7.southeast.rr.com [24.93.67.54]) by hub.freebsd.org (Postfix) with ESMTP id 0B0D837B482 for ; Sat, 19 Jan 2002 08:49:53 -0800 (PST) Received: from i8k.babbleon.org ([66.57.85.154]) by mail7.nc.rr.com with Microsoft SMTPSVC(5.5.1877.687.68); Sat, 19 Jan 2002 11:48:44 -0500 Received: by i8k.babbleon.org (Postfix, from userid 111) id 484DC3EDF; Sat, 19 Jan 2002 11:47:55 -0500 (EST) Content-Type: text/plain; charset="iso-8859-1" From: Brian T.Schellenberger To: "J.S." , freebsd-questions@FreeBSD.ORG Subject: Re: How to delete only empty directories Date: Sat, 19 Jan 2002 11:47:54 -0500 X-Mailer: KMail [version 1.3] References: <20020119111746.7fea5191.johann@broadpark.no> In-Reply-To: <20020119111746.7fea5191.johann@broadpark.no> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20020119164755.484DC3EDF@i8k.babbleon.org> 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 Saturday 19 January 2002 05:17 am, J.S. wrote: > Hi. > > I was in the middle of downloading heaps of directories with lftp, while > suddenly an error occured (I forgot to tell lftp I just changed my account > password), thus lftp created all the directories it had collected the > information of, and they became, ofcourse, empty. > > 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 find -d . -type d -empty -exec rmdir {} \; Actually you don't even need to check for empty, since rmdir refuses to delete non-empty directories. The secret, though, is the -d option to find; without it, find will keep trying to delete the directories that are above the ones that you are going to delete & you'll have to execute it over & over to get the effect you want. > what I need to remove. But it is like several hundred directories and I > ain't planning on doing it all manually =) Besides, I don't know how to > script so I'd really appreciate some help from the mighty audience. > > Thanks. > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- Brian T. Schellenberger . . . . . . . bts@wnt.sas.com (work) Brian, the man from Babble-On . . . . bts@babbleon.org (personal) http://www.babbleon.org -------> Free Dmitry Sklyarov! (let him go home) <----------- http://www.eff.org http://www.programming-freedom.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message