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 ]] && echo -e "$FOO\t\t\t-notempty-" || echo -e "$FOO\t\t\t-empty-" done < $IN_FILE
It will write a log file with -empty- or -notempty- tag lines.
Good luck
Thanks,
AKSARAV