Need to count files & create log of that.

Hi Friends,
I need some help. First look at my files hierchachy

/<level-1>/<level-2>/<level-3>/*.tif

eg. :

/2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/001/Babylon2_20100701012049_1278004849.49892_000.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/002/Babylon2_20100701012049_1278004849.49892_016.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/003/Babylon2_20100701012049_1278004849.49892_035.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/004/Babylon2_20100701012049_1278004849.49892_046.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/005/Babylon2_20100701012049_1278004849.49892_058.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/006/Babylon2_20100701012049_1278004849.49892_078.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/007/Babylon2_20100701012049_1278004849.49892_096.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/008/Babylon2_20100701012049_1278004849.49892_105.tif
./2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/009/Babylon2_20100701012049_1278004849.49892_117.tif

I want to find out the list of level-3 folders, which contain more that 2 TIF images. I want list of full path from date to that tif image.

Something like this..?

awk -F"/" 'NR==FNR{++a[$4];next} a[$4]>2 {print}' inputfile inputfile

Try this..

% awk -F"/" ' { print $4 } ' input_file | uniq -c | grep -v "1" | awk ' { print $2 }' | sed 's,^,grep \"/,g;s,$,/\" input_file,g' | sh