for dir in $(find . -type d -print 2>/dev/null | grep c| cut -d/ -f2) do cd $dir; cat ${dir}.ent if [grep tif] then echo "this is the current directory": $dir else cd .. fi done