I'm trying to write output to a file, the correct output is printed in the successful file and the same is printed in the unsuccessful log. In the unsuccessful log it should print only unsuccessful logs but it is printing successful logs also.
for TASKARN in `aws ecs list-tasks --cluster APPS --desired-status RUNNING --region us-east-1 --service-name coreservice-service | jq .taskArns[] | sed 's/.$//; s/^.//' | cut -d":" -f 6 | cut -d"/" -f 3`
do
echo $TASKARN
cd /tmp/
val=`find core-$TASKARN.log -maxdepth 0 -daystart -mtime -1`
if [ $val == core-$TASKARN.log ]
then
echo " core-$TASKARN.log is present " >> /opt/successfull.log
else
echo " core-$TASKARN.log is not present " >> /opt/unsuccessfull.log
fi
done
In successful log
core-26f374a6a.log is present
In unsuccessful log
core-26f374a6a.log is not present