From owner-cvs-all Thu Sep 2 3:56:51 1999 Delivered-To: cvs-all@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 6E06F14E0C; Thu, 2 Sep 1999 03:56:42 -0700 (PDT) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id MAA94683; Thu, 2 Sep 1999 12:56:06 +0200 (CEST) (envelope-from des) To: "Rodney W. Grimes" Cc: rgrimes@freebsd.org (Rodney W. Grimes), cvs-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/etc/mtree README References: <199908230138.SAA33709@gndrsh.dnsmgr.net> From: Dag-Erling Smorgrav Date: 02 Sep 1999 12:56:06 +0200 In-Reply-To: "Rodney W. Grimes"'s message of "Sun, 22 Aug 1999 18:38:02 -0700 (PDT)" Message-ID: Lines: 56 X-Mailer: Gnus v5.5/Emacs 19.34 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk "Rodney W. Grimes" writes: > e) Add missing and remove extra entries (producing this last one > is being a bit of a pain, anyone have a quick command to find > directories that have no entries in them?). #!/usr/bin/perl5 -w use strict; sub recurse { my $base = shift; # Where to start my @entries; # Directory listing my $entry; # Iterator for @entries local *DIR; # Directory handle if ($base ne "/") { $base =~ s#/$##; } if (!opendir(DIR, $base)) { die("opendir(): $!\n"); } if (!(@entries = readdir(DIR))) { die("readdir(): $!\n"); } closedir(DIR); if (@entries == 2) { # Contains only . and .., no files or directories warn("$base/\n"); return; } foreach $entry (@entries) { if (-d "$base/$entry" && $entry ne "." && $entry ne "..") { recurse("$base/$entry"); } } } MAIN:{ my $dir; # Iterator if (@ARGV == 0) { die("Syntax: $0 dirname ...\n"); } foreach $dir (@ARGV) { recurse($dir); } exit 0; } DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message