# $1必须是绝对路径
crurl=$1
func_hdir(){
echo $crurl
cd $crurl
for aitem in `ls -l | grep "^d" | awk ‘{print $9}‘`; do
crurl=$crurl/$aitem
func_hdir $aitem
done
dirc=`ls $crurl`
if [ "$dirc" = "" ]
then
echo $crurl
rm -rf $crurl
fi
crurl=${crurl%/*}
}
func_hdir
linux下递归删除空目录的bash实例,布布扣,bubuko.com
原文:http://arvey2888.blog.51cto.com/8885495/1540028