Find empty folders

In current folder, there are many subfolders, subfolder's subfolders... under it.

How can I find out the empty folders with no files in it.

I only need the top folder list.

For example,

I have folders like below:

a/b/c
a/b/x/x.txt
a/s
a/s/y

I need get the folder a/s, but not a/b/c ( because folder b has file), not a/b/x/x.txt (has file in it), not a/s/y (because a/s is already in list).

do you have "-empty" option in find??
just lokk into man page of find..

Thanks, but my system is on Solaris 10, no -empty option.

Seems I have to install a GNU find to get it done.

my another idea is to install CYGWIN (which I already have, and find command with -empty), map the Solaris driver by SAMBA.

I can see the driver in windows explorer, but I can't see the driver in cygwin. Any suggestion on it?

What about /usr/xpg4/bin/find

if your ls has -R,

ls -1R| nawk '/^\./{s=$0;getline;if($0==""){print "empty: "s}}'

NB:tested on linux, not solaris, but you can give nawk a try. run it on top directory where you want to start searching.

close to my request now. Thank you.

But it doesn't report the top folders only. In sample,

$ ls -1R| nawk '/^\./{s=$0;getline;if($0==""){print s}}'
./a/b:
./c:

I have more than thousand folders under that folder, I need get the top folder list of

./a (because under folder a, only have subfolder b, no any files.)
./c

---------- Post updated at 10:02 PM ---------- Previous update was at 10:00 PM ----------

same error, not support -empty.

---------- Post updated at 10:12 PM ---------- Previous update was at 10:02 PM ----------

Get it by myself

for i in `ls -l |awk '{if ($1~/^d/) print $9}'`
do 
  if  [ "$(find $i -type f)" = "" ] ; then 
       echo $i "is empty folder"
  fi
done 

But if the top folder name include space, the script will not find it out.

don't get a file name like that using ls -1 and print column 9. if you have spaces in the file name , you will not get the correct file name. Use find instead, then something to count inside each directory. Pseudocode

find . -type d | while read DIR
do
   var=`ls $DIR | wc -l `
   if var is 0  then echo "empty" fi
done