How to exclude the empty directories

Hi.,

I have a script, in which I am processing a files present in the directory types.

ls -lrt | grep ^d | grep Dir_type | awk -f '{print $9}' |\

while read dir_name; do

#operations

done

where Dir_type is the pattern in which directories get created. How to filter out empty directories in the above code.

Thanks.,

Hi hope this will help you..

for dir in $(ls)
do
    if [ -d $dir -a "$(ls -A $dir )" ]
    then
        echo $dir
    fi
done

Check the poast how to find empty folders without using -empty

ls -l * | awk '/total 0/{print last}{last=$0}'