I have written a script for clean Up activity based on some date condition. But I am getting an error.
#!/bin/bash
echo "Process Started"
Current_Date=`date +%Y-%m-%d`
echo "todays Date ==> $Current_Date"
fromDate=$1
toDate=$2
oldDate=`date --date="3 years ago" +%Y-%m-%d`
echo "Two Yrs Back Date ==> $oldDate"
if [ $toDate -le $oldDate ]
then
find . -type f -newermt $fromDate ! -newermt $toDate -exec truncate -s 0 {} \; && echo "truncated"
else
echo "todate should be less than three years"
fi
echo "Done"
Getting the error - line 15: syntax error: unexpected end of file
Although line 15 is not there script has only 14 line. Also the bash script runs fine until the command echo "Two Yrs Back Date ==> $oldDate"
.
After that it gives the error when the if
condition starts.
Just wanted to check any syntax error which I am making.