I am writing a script in bash and I need that some program check for existing files from today to 30 days ago or any number of days ago. So, the conflict part of the code is:
today=$(date +%j)
#run every monday
echo "$today"
limit="$((today - 30))"
echo "$limit"
This gives the following error:
./test4.sh: line 9: 089: value too great for base (error token is "089")
The problem seems to be the line with: limit="$((today - 30))"
I tried to find something but could not find. Any idea?
Use the following:
limit="$((10#$today - 30))"
The *10# *tells bash to interpret the value as a decimal value.
This is required because today=$(date +%j) returned 089, not a valid interger for calculus (might be interpreted as octal ?)
More informations here.