Help in searching a particular string in a file name (not inside the file contents)

Dear Unix Gurus,
I am new to shell scripting and in the process of learing.
I am trying to find whether a file name has today's date in MMDDYYYY format.
I am using the following code and it doesn't seem like working.

#!/usr/bin/ksh
today=$(date '+%m%d%Y')
echo today: $today
file=`find /opt/feeds -type f -name /opt/feeds/*.* -exec grep $today {} \;`
echo file: $file
if [ "$file" = "" ] ; then 
echo "File has today's date"
else
echo "File has different date"
fi

Please help me.

today=$(date +%m%m%Y)
ls /opt/feeds/*${today}*

will list all of the file with names like the date - just in the /opt/feed direcotry

For all directories from /opt/feeds on down:

today=$(date +%m%m%Y)
find /opt/feeds -name  "\*${today}\*"  

I am still not able to make the script work. I am not able to get the correct echo message.
I wanted to check only inside the /opt/feeds directory.

Can you please modify the script?

Thanks,
Shankar

#!/usr/bin/ksh
today=$(date '+%m%d%Y')
echo today: $today
file=`ls /opt/feeds | grep "$today"`
if [ -z "$file" ] ; then
   echo 'file not found'
else
   echo "file found = $file"
fi
1 Like

Thank you Jim. It works like a charm!!!!