Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: listing/deleting empty directories recursively



On Nov 19,  5:07pm, zzapper wrote:
} Subject: Re: listing/deleting empty directories recursively
}
} >    rmdir --verbose **/*(/od)
} I presume this can be xarg?

Or zargs, as Stephane suggested.

} The disadvantage of this is that it produces a flood of warning
} messages which may prevent you spotting something untoward.

I guess the question is whether you want a short command or minimal
output.  You can do the recursive descent yourself, of course.

    function rmemptydir() {
      emulate -RL zsh
      local here=$REPLY
      local -a deep
      deep=( $here/*(N/+rmemptydir) )
      [[ -n $deep ]] && rmdir --verbose $deep
      reply=( $here(N^F) )
    }
    : *(N/+rmemptydir)

This all assumes a version of zsh recent enough that recursive calls
to the (e) glob qualifier don't cause a crash, and so that you have
the (+) qualifier shortcut.



Messages sorted by: Reverse Date, Date, Thread, Author