Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Tip of the day: prune empty directory hierarchies
- X-seq: zsh-users 20285
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Users' List <zsh-users@xxxxxxx>
- Subject: Tip of the day: prune empty directory hierarchies
- Date: Mon, 29 Jun 2015 15:59:27 +0100
- 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
- Organization: Samsung Cambridge Solution Centre
In case anybody ever wanted this and there isn't a standard solution I
don't know about...
pws
# Prune empty directory hierarchies below the current directory. That's
# a hierarchy where everything underneath is itself a directory.
#
# The first search is slow, but subsequently it simply goes up one
# directory each time so it's much faster.
local -aU dirs
dirs=(**/*(ND/^F))
while (( ${#dirs} )); do
rmdir $dirs || return
# print Pruhed ${#dirs} directories...
dirs=(${^dirs:h}(ND/^F))
done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author