I am getting this really weird error despite of the fact that the same script runs fine on one platform (Arch linux) but not on my other mobile platform (Maemo Linux). I'll pass here the relevant part of the code with the line numbering:
41 for DIR in $DIRS
42 do
43 tempdir=$DIR/
44 tempval=$(stat -c %Y $tempdir)
45 echo $tempval
46 if (( $tempval > $(date +%s) - 3600*24*30 )); then
47 echo "I am done basically. Exiting..."
48 exit
49 else
50 continue
51 fi
52 done
In the code above DIRS is a list which contains names of directories. In this loop i am trying to find one directory of the list which is newer than 30 days old and if i find one i exit the script.
Line 45 is put there for debugging purposes basically.
I am getting the error below:
./script.sh : line 52 : 1372757584 : not found
After some changes suggested from the comments:
Ok the error now is below:
scone.sh: line 46: ((: 1372768246 -gt 1372770593 - 3600*24*30 : syntax error
in expression (error token is "1372770593 - 3600*24*30 ")
bash -vx ./script.sh
. Are the bash versions on the two platforms different? You may useif [ "$tempval" -gt $(($(date +%s) - 3600*24*30)) ]
instead. – Hauke Laging Jul 2 '13 at 11:31bash
in both instances? And/or could there be a runaway construct which starts somewhere in lines 1-40 which ends at line 52 and expands to the number you see? – tripleee Jul 2 '13 at 11:47-gt
only works with[
and[[
. – Evan Teitelman Jul 2 '13 at 14:22