Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Selecting leaf directories only
- X-seq: zsh-users 3609
- From: "Nadav Har'El" <nyh@xxxxxxxxxxxxxxxxxxx>
- To: Andrej Borsenkow <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- Subject: Re: Selecting leaf directories only
- Date: Wed, 7 Feb 2001 12:46:19 +0200
- Cc: zsh-users@xxxxxxxxxx
- Hebrew-date: 14 Shevat 5761
- In-reply-to: <000a01c090ef$5d8625f0$21c9ca95@xxxxxxxxxxxxxx>; from Andrej.Borsenkow@xxxxxxxxxxxxxx on Wed, Feb 07, 2001 at 01:18:50PM +0300
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20010207110542.A1355@xxxxxxxxx> <000a01c090ef$5d8625f0$21c9ca95@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxx |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Why do doctors call what they do
http://nadav.harel.org.il |practice? Think about it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author