Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jan 2002 11:47:54 -0500
From:      Brian T.Schellenberger <bts@babbleon.org>
To:        "J.S." <johann@broadpark.no>, freebsd-questions@FreeBSD.ORG
Subject:   Re: How to delete only empty directories
Message-ID:  <20020119164755.484DC3EDF@i8k.babbleon.org>
In-Reply-To: <20020119111746.7fea5191.johann@broadpark.no>
References:  <20020119111746.7fea5191.johann@broadpark.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020119164755.484DC3EDF>