Skip to main content
More expressive title
Link
jasonwryan
  • 74.9k
  • 35
  • 204
  • 230

./script.sh : line 52 : 1372757584 : not found Expression error in bash script

Cleaned up the bottom part of the post.
Source Link
user26112
user26112

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////////////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 ")




 

??

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 ")

??

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 ")




 
deleted 546 characters in body
Source Link

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 ")

??

///////////////////////Final Solution///////////////////

I've actually made the changes suggested by the 3 guys at the comments and all of them were necessary for the script to work.

Final code below:

temptime=$(date +%s)
temptime=`expr $temptime - 2592000`

for DIR in $DIRS
do
tempdir=$DIR/
echo $tempdir
tempval=$(stat -c %Y $tempdir)
echo $tempval
if [[ $tempval -gt $temptime ]]; then
    echo "Exiting gracefully!!!"
    exit
else
    continue
fi
done

 

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 ")

??

///////////////////////Final Solution///////////////////

I've actually made the changes suggested by the 3 guys at the comments and all of them were necessary for the script to work.

Final code below:

temptime=$(date +%s)
temptime=`expr $temptime - 2592000`

for DIR in $DIRS
do
tempdir=$DIR/
echo $tempdir
tempval=$(stat -c %Y $tempdir)
echo $tempval
if [[ $tempval -gt $temptime ]]; then
    echo "Exiting gracefully!!!"
    exit
else
    continue
fi
done

 

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 ")

??

Removed [solved].
Link
user26112
user26112
Loading
added 555 characters in body; edited title
Source Link
Loading
2nd attempt
Source Link
Loading
Source Link
Loading