I am running into an issue that I can't quite figure out. I have a BASH script which recurses through directories and compares the current date to the file-modified time of the file. If it is beyond a certain age, the file gets gzipped.
I am receiving the following error:
./serversync.sh: line 87: 1324308130-1323116622
1323581504: syntax error in expression (error token is "1323581504")
The section of code that is running at this point is cited below:
#If the file doesn't have a matching .gz file, compress it
do if [ ! -e ${FILE}.gz ]
then
echo "Matching Gzip doesn't exist for $FILE"
echo Checking to see if compression needed
#test to make sure that the file is 30 days old, and if it is, gzip
FILEMTIME=$(stat -c %Y $FILE)
FILEAGE=$(($DATE-$FILEMTIME))
echo fileage is $FILEAGE
if [ $FILEAGE -gt $COMPRESSWINDOWSTART -a $FILEAGE -lt $COMPRESSWINDOWEND ]
then
echo $FILEAGE is greater than $COMPRESSWINDOWSTART and less than $COMPRESSWINDOWEND
echo Compressing $FILE
gzip $FILE
fi
fi
Line 87 is this line:
FILEAGE=$(($DATE-$FILEMTIME))
If anyone can offer any ideas on why this happens id apprciate it!
Best Answer
try
What you had was looking for a variable called "1324308130-1323116622" rather than trying to evaluate the expression.