Midhun Midhun - 1 year ago 72
Bash Question

Find directories not containing a file recursively

I want to find the directories which does not having any files.Below is the sample script which will write a sample file with all the directory names.

CURRENT_DATE=`date +'%d%m%Y'`
Year=`date +%Y`
cd $File_Path
echo $Year
find /bishare/DLSFTP/$Year* -type d -exec ls -dlrt {} + > $Temp_Path/Vendors_Data_$CURRENT_DATE.txt

Answer Source

If I understand well, you're looking for empty directory.

You can use the -empty parameter of find command for that:

find /bishare/DLSFTP/$Year* -type d -empty
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download