* Selecting leaf directories only
@ 2001-02-07 7:44 Andrej Borsenkow
2001-02-07 8:59 ` Geoff Wing
2001-02-07 10:05 ` Akos Szalkai
0 siblings, 2 replies; 9+ messages in thread
From: Andrej Borsenkow @ 2001-02-07 7:44 UTC (permalink / raw)
To: ZSH users mailing list
**/*(/) gives me all (sub-)directories. Any easy way to get leaf directories
only? I.e. in case
foo/
bar/
baz/
the above gives me ``foo foo/bar foo/baz'' while I want ``foo/bar foo/baz''
only.
-andrej
Have a nice DOS!
B >>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting leaf directories only
2001-02-07 7:44 Selecting leaf directories only Andrej Borsenkow
@ 2001-02-07 8:59 ` Geoff Wing
2001-02-07 9:21 ` Andrej Borsenkow
2001-02-07 10:05 ` Akos Szalkai
1 sibling, 1 reply; 9+ messages in thread
From: Geoff Wing @ 2001-02-07 8:59 UTC (permalink / raw)
To: zsh-users
Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru> typed:
:**/*(/) gives me all (sub-)directories. Any easy way to get leaf directories
:only? I.e. in case
:the above gives me ``foo foo/bar foo/baz'' while I want ``foo/bar foo/baz''
:only.
*/**/*(/)
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Selecting leaf directories only
2001-02-07 8:59 ` Geoff Wing
@ 2001-02-07 9:21 ` Andrej Borsenkow
2001-02-07 9:29 ` Andrej Borsenkow
0 siblings, 1 reply; 9+ messages in thread
From: Andrej Borsenkow @ 2001-02-07 9:21 UTC (permalink / raw)
To: zsh-users
>
> Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru> typed:
> :**/*(/) gives me all (sub-)directories. Any easy way to get leaf
> directories
> :only? I.e. in case
> :the above gives me ``foo foo/bar foo/baz'' while I want ``foo/bar foo/baz''
> :only.
>
> */**/*(/)
>
>
Black magic. Awesome :-)
But it does not completely solve the problem (it does in my specific case,
thank you). It needs at least two levels; i.e. in case
foo/
bar1/
bar2/
baz/
it skips ``baz'' that is leaf directory as well.
-andrej
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Selecting leaf directories only
2001-02-07 9:21 ` Andrej Borsenkow
@ 2001-02-07 9:29 ` Andrej Borsenkow
2001-02-07 17:15 ` Artur Penttinen
0 siblings, 1 reply; 9+ messages in thread
From: Andrej Borsenkow @ 2001-02-07 9:29 UTC (permalink / raw)
To: zsh-users
>
> Black magic. Awesome :-)
>
> But it does not completely solve the problem (it does in my specific case,
> thank you). It needs at least two levels;
Actually, it works with exactly two levels only:
bor@itsrm2% mkdir -p foo/bar/{baz1,baz2}
bor@itsrm2% print -l */**/*(/)
foo/bar
^^^^^^^
foo/bar/baz1
foo/bar/baz2
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting leaf directories only
2001-02-07 7:44 Selecting leaf directories only Andrej Borsenkow
2001-02-07 8:59 ` Geoff Wing
@ 2001-02-07 10:05 ` Akos Szalkai
2001-02-07 10:18 ` Andrej Borsenkow
1 sibling, 1 reply; 9+ messages in thread
From: Akos Szalkai @ 2001-02-07 10:05 UTC (permalink / raw)
To: Andrej Borsenkow; +Cc: zsh-users
On Wed, Feb 07, 2001 at 10:44:31AM +0300, Andrej Borsenkow wrote:
> **/*(/) gives me all (sub-)directories. Any easy way to get leaf directories
> only? I.e. in case
Isn't it true that the link count of leaf directories is exactly 2?
Therefore I would try **/*(/l2) .
Regards,
Akos
--
Akos Szalkai <szalkai@2f.hu>
IT Consultant
2F 2000 Szamitastechnikai es Szolgaltato Kft.
Tel: (+36-1)-4887700 Fax: (+36-1)-4887709 WWW: http://www.2f.hu/
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Selecting leaf directories only
2001-02-07 10:05 ` Akos Szalkai
@ 2001-02-07 10:18 ` Andrej Borsenkow
2001-02-07 10:46 ` Nadav Har'El
0 siblings, 1 reply; 9+ messages in thread
From: Andrej Borsenkow @ 2001-02-07 10:18 UTC (permalink / raw)
To: zsh-users
>
> 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 :-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting leaf directories only
2001-02-07 10:18 ` Andrej Borsenkow
@ 2001-02-07 10:46 ` Nadav Har'El
2001-02-07 12:07 ` Andrej Borsenkow
0 siblings, 1 reply; 9+ messages in thread
From: Nadav Har'El @ 2001-02-07 10:46 UTC (permalink / raw)
To: Andrej Borsenkow; +Cc: zsh-users
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Selecting leaf directories only
2001-02-07 10:46 ` Nadav Har'El
@ 2001-02-07 12:07 ` Andrej Borsenkow
0 siblings, 0 replies; 9+ messages in thread
From: Andrej Borsenkow @ 2001-02-07 12:07 UTC (permalink / raw)
To: zsh-users
>
> 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.
Actually, even on standard Unix filesystem root can create hard links to
directories (that depends on definition of "standard" of course. It was
possible on original Unix filesystem, I believe, it is possible on UFS but
impossible on Veritas). But I needed it for stable, well defined, environment
and link count is quite enough.
Thanks to everybdoy
-andrej
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Selecting leaf directories only
2001-02-07 9:29 ` Andrej Borsenkow
@ 2001-02-07 17:15 ` Artur Penttinen
0 siblings, 0 replies; 9+ messages in thread
From: Artur Penttinen @ 2001-02-07 17:15 UTC (permalink / raw)
To: ZSH Users
On Wed, 7 Feb 2001, Andrej Borsenkow wrote:
> From: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
> To: zsh-users@sunsite.auc.dk
> Subject: RE: Selecting leaf directories only
> Date: Wed, 7 Feb 2001 12:29:53 +0300
> X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
> X-Procmail-List: Z Shell Users Mailing List
>
> >
> > Black magic. Awesome :-)
> >
> > But it does not completely solve the problem (it does in my specific case,
> > thank you). It needs at least two levels;
>
> Actually, it works with exactly two levels only:
>
> bor@itsrm2% mkdir -p foo/bar/{baz1,baz2}
> bor@itsrm2% print -l */**/*(/)
> foo/bar
> ^^^^^^^
> foo/bar/baz1
> foo/bar/baz2
# mkdir -p foo/bar/{baz1,baz2}
# print -l */**/*(/)
foo/bar
foo/bar/baz1
foo/bar/baz2
# print -l */*/*(/)
foo/bar/baz1
foo/bar/baz2
wbw,artur
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2001-02-07 12:08 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-07 7:44 Selecting leaf directories only Andrej Borsenkow
2001-02-07 8:59 ` Geoff Wing
2001-02-07 9:21 ` Andrej Borsenkow
2001-02-07 9:29 ` Andrej Borsenkow
2001-02-07 17:15 ` Artur Penttinen
2001-02-07 10:05 ` Akos Szalkai
2001-02-07 10:18 ` Andrej Borsenkow
2001-02-07 10:46 ` Nadav Har'El
2001-02-07 12:07 ` Andrej Borsenkow
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).