Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: listing sub-drectories with most files in
- X-seq: zsh-users 16305
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: listing sub-drectories with most files in
- Date: Fri, 02 Sep 2011 11:59:54 -0700
- In-reply-to: <Xns9F54C66661059zzappergmailcom@80.91.229.10>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <Xns9F54A6DEAC33Bzzappergmailcom@80.91.229.10> <110902100313.ZM8455@torch.brasslantern.com> <Xns9F54C66661059zzappergmailcom@80.91.229.10>
On Sep 2, 6:30pm, zzapper wrote:
} Subject: Re: listing sub-drectories with most files in
}
} Bart Schaefer wrote in news:110902100313.ZM8455@xxxxxxxxxxxxxxxxxxxxxx:
} >
} > This will give you the directories and the count of files in each,
} > in ascending order by number of files:
} >
} > print **/*(/ne{'reply=($REPLY/*(N.)); reply=($#reply\:$REPLY)'})
I should probably note that the above triggers some pathologically-bad
globbing behavior in older versions of zsh e.g. 4.2.x for some values
of x. It may hang your shell for a VERY long time.
} Minor quibble: on my system (Cygwin) it all jumbled onto one line
Well, yes. To put one directory on each line:
print -l **/*(/ne{'reply=($REPLY/*(N.)); reply=($#reply\:$REPLY)'})
Or you can assign to a variable
dircounts=( **/*(/ne{'reply=($REPLY/*(N.)); reply=($#reply\:$REPLY)'}) )
and then do as you will.
} Also in reverse order but that's not a problem.
You mean you got the directories with the largest number of files
first in the list? I'm not sure why that would happen. In my zsh
build tree (separate from the source tree) for example I get:
1:Completion
1:Config
1:Etc
1:Functions
2:Src/Aliases
8:Test
9:Doc
18:Src/Builtins
81:Src/Modules
109:Src/Zle
147:Src
If you want the big ones first, change "/n" to "/nOn" in the flags.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author