Need a script to check for a file with yesterdays date in the name

Soldato
Joined
9 May 2005
Posts
7,400
Location
Berkshire
Can anyone help me with this, I'm not quite sure how to get a script to check for a file that's named something like "file-dategoeshere.xls". The report is genereated daily, and I want a script to check if the file has run for that day and then send out an e-mail if it hasn't. The e-mail part I can do but I'm stumped on the checking of the name.

Anyone got any ideas?
 
I ended up using a variation of this:

Code:
#!/bin/bash
DATE=`date +%e-%m-%y`
FILE=/home/jesus/Heaven/file-$DATE.xls

if [ -f $FILE ]
then
echo "file exists!"
fi

With some minor changes

Code:
#!/bin/bash
cd /path/to/report/folder
DATE=`date [U]--date=yesterday[/U] +%e-%m-%Y`
FILE=[U]*[/U]$DATE.xls
if [ -f $FILE ]
then
echo "file exists!"
[U]else
echo "file does not exist!"
cd /path/to/mail/script
php -q mailer.php[/U]
fi

The report names contains a load of spaces which was buggering up line 5, so it was easier to *$DATE.xls.
 
Back
Top Bottom