Article View: news.software.nntp
Article #15382Re: A script to find and remove empty directories
From: Jeff Garzik
Date: Wed, 26 Feb 1997 00:00
Date: Wed, 26 Feb 1997 00:00
34 lines
1973 bytes
1973 bytes
(courtesy copy sent via e-mail) Miquel van Smoorenburg wrote: > >> >>>>> On 25 Feb 1997, Jeff Garzik <jeff.garzik@spinne.com> wrote: > >> JG> Here is a quick and dirty Perl script that removes empty directories > >> JG> recursively. There may be some way to do this with shell utils, but it > >> JG> was faster for me to simply write this. :) It should be easy to modify > >> JG> the output to show newsgroups removed, for logging purposes or > >> JG> whatever. > find /var/spool/news -type d -empty -depth | xargs -r rmdir I just checked this with strace under Linux. This command stats *every* file in /var/spool/news to determine whether it is a directory or not. (-type d) My script reads the directory, then skips all files with all-digit filenames, so only directories are stat'd. (special cases like alt.2600 fall through the cracks) There is a big performance difference when you are talking about hundreds of thousands of files. Jeff -- "The New York Times is read by the people who run the country. The Washington Post is read by the people who think they run the country. The National Enquirer is read by the people who think Elvis is alive and running the country ..." -- Robert J Woodhead
Technical Details
Message-ID:
<33151126.62263939@spinne.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<33132F95.54538512@spinne.com> <82ybccj8wr.fsf@parrot.eecs.umich.edu> <3313F711.79B8AA0A@spinne.com> <5f1ja3$1nk$1@Q.cistron.nl>Show Full Headers
Complete Article Headers
Message-ID: <33151126.62263939@spinne.com> Subject: Re: A script to find and remove empty directories Date: Wed, 26 Feb 1997 00:00:00 +0000 From: Jeff Garzik <jeff.garzik@spinne.com> References: <33132F95.54538512@spinne.com> <82ybccj8wr.fsf@parrot.eecs.umich.edu> <3313F711.79B8AA0A@spinne.com> <5f1ja3$1nk$1@Q.cistron.nl> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 221745171 To: Miquel van Smoorenburg <miquels@cistron.nl> Organization: Spinne http://spinne.com Newsgroups: news.software.nntp