Midhun Midhun - 2 months ago 7
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.

#!/bin/bash
CURRENT_DATE=`date +'%d%m%Y'`
Year=`date +%Y`
Temp_Path=/appinfprd/bi/infogix/IA83/InfogixClient/Scripts/IRP/
File_Path=/bishare/DLSFTP/
cd $File_Path
echo $Year
find /bishare/DLSFTP/$Year* -type d -exec ls -dlrt {} + > $Temp_Path/Vendors_Data_$CURRENT_DATE.txt

Answer

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
Comments