From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14015 invoked from network); 7 Feb 2001 10:56:27 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 Feb 2001 10:56:27 -0000 Received: (qmail 26575 invoked by alias); 7 Feb 2001 10:56:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3609 Received: (qmail 26564 invoked from network); 7 Feb 2001 10:55:57 -0000 Date: Wed, 7 Feb 2001 12:46:19 +0200 From: "Nadav Har'El" To: Andrej Borsenkow Cc: zsh-users@sunsite.dk Subject: Re: Selecting leaf directories only Message-ID: <20010207124619.F2450@leeor.math.technion.ac.il> References: <20010207110542.A1355@2fkft.com> <000a01c090ef$5d8625f0$21c9ca95@mow.siemens.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2i In-Reply-To: <000a01c090ef$5d8625f0$21c9ca95@mow.siemens.ru>; from Andrej.Borsenkow@mow.siemens.ru on Wed, Feb 07, 2001 at 01:18:50PM +0300 Hebrew-Date: 14 Shevat 5761 On Wed, Feb 07, 2001, Andrej Borsenkow wrote about "RE: Selecting leaf directories only": > > > > Isn't it true that the link count of leaf directories is exactly 2? > > Therefore I would try **/*(/l2) . > > > > Yep. Now that's real black magic :-) Just watch out - the fact that the number of links of a directory is 2 plus the number of its subdirectories, is true only on standard Unix filesystems. If you mount a filesystem through SMB, or a CD-ROM, for example, it is no longer true. A relevant quote from the GNU find(1) manual that discusses this issue: -noleaf Do not optimize by assuming that directories con­ tain 2 fewer subdirectories than their hard link count. This option is needed when searching filesystems that do not follow the Unix directory- link convention, such as CD-ROM or MS-DOS filesys­ tems or AFS volume mount points. Each directory on a normal Unix filesystem has at least 2 hard links: its name and its `.' entry. Additionally, its subdirectories (if any) each have a `..' entry linked to that directory. When find is examining a directory, after it has statted 2 fewer subdirecto­ ries than the directory's link count, it knows that the rest of the entries in the directory are non- directories (`leaf' files in the directory tree). If only the files' names need to be examined, there is no need to stat them; this gives a significant increase in search speed. -- Nadav Har'El | Wednesday, Feb 7 2001, 14 Shevat 5761 nyh@math.technion.ac.il |----------------------------------------- Phone: +972-53-245868, ICQ 13349191 |Why do doctors call what they do http://nadav.harel.org.il |practice? Think about it.