Red Hat Bugzilla – Bug 431350
error using date in bash
Last modified: 2008-02-04 11:38:04 EST
Description of problem:
Version-Release number of selected component (if applicable):
Steps to Reproduce:
2.echo $(($(echo $TEST)-1)) - executes
3.echo $(($(date +'%H')-1)) - executes
4.echo $(($(date +'%y')-1)) - error
5.echo $(($(date +'%m')-1)) - same error if month is AUGUST
bash: 08: value too great for base (error token is "08")
In the year 2008, the answer should be 7
The problem could be in date or bash.
The problem is long standing, maybe about 3-4 year. Had reported earlier also, a
long time back.
Is there any documentation that would suggest this is a violation of some
standard or something? bash interprets numbers beginning with zero as octal
numbers. The date manpage says that when using the '-' flag, numbers are not
The following commands work:
> echo $(($(date +'%-y')-1))
> echo $(($(date +'%-m')-1))
May I close this notabug?
You are right. My bad. Sorry for bothering you. I never came to understand the
error message as it was not clear enough. But one thing is still unclear, why
does it happen when the output is 08 only. The command runs without error if
output is less than 08 or ( as far as remember ) above 10, I think.
You may of course close the bug except that one issue.
Well, 07 is a valid octal number, right? And 10 is not interpreted as octal,