bash error as [[: 08: value too great for base (error token is "08")
Hi All,
I am testing conditions with below script and wanted to run the commands on all of the day but only execpt the date of month 1st and except the day of sunday. Code:
$ cat test1 Code:
sudo date 060100002013 Then I changed to Sunday date. Code:
sudo date 060900002013 Code:
[[: 08: value too great for base (error token is "08") Thanks in adavance for your kind help. |
The leading zero makes "08" look like an octal number with an invalid digit. Either tell the date command to pad with spaces rather than zero ("date +%e" or "date +%_d"), or else explicitly identify the base when you use the value:
Code:
if [[ 10#$Today_Date -ne 1 || $Today_Week -gt 0 ]]; then |
Thanks for the reply rknichols,
But still both methods are not working for me. Code:
$ date |
Try
Code:
#!/bin/bash |
Quote:
Thanks a lot to LinuxQuestions.Org |
Read up here for more detail on how bash treats leading zeroes, and how to handle them:
http://mywiki.wooledge.org/ArithmeticExpression http://mywiki.wooledge.org/BashFAQ/018 Edit: BTW, you can combine your two date calls into one, like this: Code:
read Today_Date Today_Week < <( date '+%e %w' ) http://mywiki.wooledge.org/BashFAQ/031 http://mywiki.wooledge.org/ArithmeticExpression Since these are numeric tests, you should be using: Code:
if (( Today_Date != 1 && Today_Week > 0 )); then |
All times are GMT -5. The time now is 01:31 AM. |