From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1087 invoked by alias); 2 Sep 2011 19:00:15 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16305 Received: (qmail 26778 invoked from network); 2 Sep 2011 19:00:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110902115954.ZM8658@torch.brasslantern.com> Date: Fri, 02 Sep 2011 11:59:54 -0700 In-reply-to: Comments: In reply to zzapper "Re: listing sub-drectories with most files in" (Sep 2, 6:30pm) References: <110902100313.ZM8455@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: listing sub-drectories with most files in MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 2, 6:30pm, zzapper wrote: } Subject: Re: listing sub-drectories with most files in } } Bart Schaefer wrote in news:110902100313.ZM8455@torch.brasslantern.com: } > } > 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.