🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #15359

Re: A script to find and remove empty directories

#15359
From: Miquel van Smoorenburg
Date: Wed, 26 Feb 1997 00:00
34 lines
1858 bytes
In article <5f27vi$58m$1@shell3.ba.best.com>,
Jef Poskanzer  <jef@acme.com> wrote:
>miquels@cistron.nl (Miquel van Smoorenburg):
>}find /var/spool/news -type d -empty -depth | xargs -r rmdir
>
>Some versions of find need an explicit -print.  Some versions of find
>don't have -empty and/or -depth; the -empty is not necessary, and the
>-depth can be replaced with a sort -r step.  I don't even know what the
>-r on xargs is for.  This command should work everywhere:
>
>find /var/spool/news -type d -print | sort -r | xargs rmdir

You're absolutely right ofcourse. I've gotten used to Linux and other
systems with GNU utils too much, I think :).

By the way, the "-r" to xargs is useful:

       --no-run-if-empty, -r
              If  the  standard  input  does not contain any non�
              blanks, do not run the command.  Normally, the com�
              mand is run once even if there is no input.

It prevents

rmdir: too few arguments
Try `rmdir --help' for more information.

But I digress.. as usual with any Usenet posting ofcourse. I'm just holding
up tradition :)

Mike.

Technical Details
Message-ID: <5f2f9n$7bt$1@holodeck.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
References: <33132F95.54538512@spinne.com> <3313F711.79B8AA0A@spinne.com> <5f1ja3$1nk$1@Q.cistron.nl> <5f27vi$58m$1@shell3.ba.best.com>

Show Full Headers
Complete Article Headers
Message-ID: <5f2f9n$7bt$1@holodeck.cistron.nl>
Subject: Re: A script to find and remove empty directories
Date: Wed, 26 Feb 1997 00:00:00 +0000
From: miquels@cistron.nl (Miquel van Smoorenburg)
References: <33132F95.54538512@spinne.com> <3313F711.79B8AA0A@spinne.com> <5f1ja3$1nk$1@Q.cistron.nl> <5f27vi$58m$1@shell3.ba.best.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-mail
X-Deja-AN: 221667706
Distribution: inet
X-Server-Date: 26 Feb 1997 23:00:31 GMT
Organization: Cistron Internet Services B.V.
Newsgroups: news.software.nntp