zsh-workers
 help / color / mirror / code / Atom feed
* Re: Tip of the day: prune empty directory hierarchies
       [not found] <20150629155927.289729cb__2821.95612458072$1435590676$gmane$org@pwslap01u.europe.root.pri>
  2015-06-29 15:43 ` Tip of the day: prune empty directory hierarchies Stephane Chazelas
@ 2015-06-29 15:47 ` Stephane Chazelas
  1 sibling, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2015-06-29 15:47 UTC (permalink / raw)
  To: zsh-workers

2015-06-29 14:59:27 +0000, Peter Stephenson:
[...]
> # Prune empty directory hierarchies below the current directory.  That's
> # a hierarchy where everything underneath is itself a directory.
[...]

If you don't mind the error messages,

rmdir -p -- **/*(D/^F)

should work (I think).

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tip of the day: prune empty directory hierarchies
       [not found] ` <XnsA4CCD67999476davidrayninfocouk__25443.3464644992$1435953977$gmane$org@80.91.229.13>
@ 2015-07-03 20:29   ` Stephane Chazelas
  0 siblings, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2015-07-03 20:29 UTC (permalink / raw)
  To: zsh-workers

2015-07-03 20:04:41 +0000, zzapper:
> Peter Stephenson <p.stephenson@samsung.com> wrote in 
> news:20150629155927.289729cb@pwslap01u.europe.root.pri:
> 
> > dirs=(**/*(ND/^F))
> 
> I'd appreciate a fuller explanation
[...]

**/* recursive glob: any file in current directory and  below.
(ND/^F): glob qualifier: modify glob behaviour and further
filter files based on other attributes than name:
N: don't fail and don't expand to anything if there's no match
(nullglob)
D: include dot files and descend into dot dirs (don't ignore
hidden files).
/: select only files of type directory
^F: directories that are /not-full/. a "full" directory here is
one that contains at least one entry other than . and ..

Do **/*(ND/^F) is the list of empty directories (recursively).

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tip of the day: prune empty directory hierarchies
       [not found] <20150629155927.289729cb__2821.95612458072$1435590676$gmane$org@pwslap01u.europe.root.pri>
@ 2015-06-29 15:43 ` Stephane Chazelas
  2015-06-29 15:47 ` Stephane Chazelas
  1 sibling, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2015-06-29 15:43 UTC (permalink / raw)
  To: zsh-workers

2015-06-29 15:59:27 +0100, Peter Stephenson:
[...]
> local -aU dirs
> 
> dirs=(**/*(ND/^F))
> while (( ${#dirs} )); do
>   rmdir $dirs || return
[...]

Missing -- above.

With GNU `find`:

find . -depth -type d -empty -delete

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-03 20:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20150629155927.289729cb__2821.95612458072$1435590676$gmane$org@pwslap01u.europe.root.pri>
2015-06-29 15:43 ` Tip of the day: prune empty directory hierarchies Stephane Chazelas
2015-06-29 15:47 ` Stephane Chazelas
     [not found] <20150629155927.289729cb@pwslap01u.europe.root.pri>
     [not found] ` <XnsA4CCD67999476davidrayninfocouk__25443.3464644992$1435953977$gmane$org@80.91.229.13>
2015-07-03 20:29   ` Stephane Chazelas

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).