#!/bin/bash
mdate="$(date | awk '{print $2$3}')";
cd /var/tmp/precheck;
found="$(ls -l *.txt | awk '{print $6$7}')"
for txtdate in $found
do
if [ $mdate = $txtdate ]; then
echo "Pre-Check Success"
else
echo "Pre-Check FAILURE"
fi
done
In the above script, .txt files verified with current date. If the date stamp matches, it returns SUCCESS else FAILURE..
Here, it works for me except it returns condition for all files. I need only one condition to be returned: either SUCCESS or FAILURE.
If any one of the files not matches with current date stamp, it should return one failure condition. If all matches it should return only one SUCCESS condition.