The Objective of this post gives you a hack to find Empty Directories in Unix Where there is no -empty option supported with the find command
I have recently had a requirement of finding the empty directories in mount point (or) file system where there is no "-empty" option of find command is supported/available.
if its there. Its very simple just like given below
find . -type d -empty
This is the alternate way to get it done.
There are few Sub directories under mount point
Take a list of them into a text file. I named it as testfilehere.
I have designed this sample script to do the work for me.
#!/bin/bash IN_FILE=$1 while read FOO;do VAR1=`echo $FOO|sed 's/ /*/g'` list=`ls -A $VAR1|wc -l` [[ $list -ne 0 ]] &amp;&amp; echo -e &quot;$FOO\t\t\t-notempty-&quot; || echo -e &quot;$FOO\t\t\t-empty-&quot; done &lt; $IN_FILE
It will write a log file with -empty- or -notempty- tag lines.