>>>>> "Andreas" == Andreas Seidl writes: Andreas> I have written the following script, which is as good as I can do at Andreas> the moment.
Andreas> ----- begin ----- Andreas> #!/usr/bin/bash Andreas> # rmed -- remove empty directories recursively Andreas> # usage: rmed [DIR] where DIR is an optional argument, the directory Andreas> # where to start examining. Andreas> # limitations: Andreas> # - spaces in file or direcory names Andreas> # - currently still prints instead of removing (remove # in line 19) Andreas> if [ -z "$1" ] ; then Andreas> basedir="." Andreas> else Andreas> basedir=$1 Andreas> fi Andreas> cd $basedir Andreas> dirs=`\ls -F | grep '/' | sed sx/xx` Andreas> for dir in $dirs ; do Andreas> #echo " examining $dir" Andreas> if [ -z "`\ls $dir`" ] ; then Andreas> echo "empty: `pwd`/$dir" Andreas> #rmdir $dir Andreas> else Andreas> rmed $dir Andreas> fi Andreas> done Andreas> cd - Andreas> ----- end ----- Here is another one from o http://www.shelldorado.com/scripts/categories.html ----------- cut here ------------------------------- : # rmemptydir - remove empty directories # Heiner Steven ([EMAIL PROTECTED]), 2000-07-17 # # Category: File Utilities [ $# -lt 1 ] && set -- . find "$@" -type d -depth -print | while read dir do [ `ls "$dir" | wc -l` -lt 1 ] || continue echo >&2 "$0: removing empty directory: $dir" rmdir "$dir" || exit $? done exit 0 ----------- cut here ------------------------------- Ciao Volker