This is a simple script just to see if the file has been downloaded. On this script the find command always evaluated to zero – even if it didn’t find anything. So I commented it out.
filename="day_CTRwFEES_hoo01M_" I had to add an underscore to the end of the filename.
Using an underscore
$filename_$yesterday.CSV to separate the two did not work. – I had to take out the underscore, add it to the filename and then combine the variables to make it work like this –
How could I get it to work without adding the underscore to the end of the variable
#!/bin/bash set -x dayofweek=$(/bin/date +%w) today=$(/bin/date +%Y%m%d) yesterday=$(/bin/date -d "1 day ago" +%Y%m%d) friday_morning=$(/bin/date -d "3 days ago" +%Y%m%d) filename="day_CTRwFEES_hoo01M_" #if find /data/today/ -type f -name "$filename_$yesterday.CSV" ; then if ls "/data/today/$filename$yesterday.CSV" ; then echo "successful" else echo "$filename$yesterday.CSV was not downloaded, please check." | mail -s "$filename$yesterday.CSV not downloaded" [email protected]_bank.com fi [email protected]_host5981dap:~/walt/morning_checks$ ./check_day_CTRwFEES_hoo01M ++ /bin/date +%w + dayofweek=5 ++ /bin/date +%Y%m%d + today=20141024 ++ /bin/date -d '1 day ago' +%Y%m%d + yesterday=20141023 ++ /bin/date -d '3 days ago' +%Y%m%d + friday_morning=20141021 + filename=day_CTRwFEES_hoo01M_ + ls data/today/day_CTRwFEES_hoo01M_20141023.CSV /data/today/day_CTRwFEES_hoo01M_20141023.CSV + echo successful successful