zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: listing sub-drectories with most files in
Date: Fri, 02 Sep 2011 11:59:54 -0700	[thread overview]
Message-ID: <110902115954.ZM8658@torch.brasslantern.com> (raw)
In-Reply-To: <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@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.


  reply	other threads:[~2011-09-02 19:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02 15:24 zzapper
2011-09-02 17:03 ` Bart Schaefer
2011-09-02 18:30   ` zzapper
2011-09-02 18:59     ` Bart Schaefer [this message]
2011-09-03 12:02 ` Thor Andreassen
2011-09-03 15:13   ` Bart Schaefer
2011-09-03 19:23     ` Thor Andreassen
2011-09-03 21:59       ` Bart Schaefer
2011-09-04  0:34         ` Thor Andreassen
2011-09-10 17:53   ` Aaron Davies
2011-09-10 19:37     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=110902115954.ZM8658@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).