LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2009, 02:06 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
run error


if [[ ! $((`date +%d`)) -eq 8 ]]
then
echo test1
else
echo test2
fi


I have a script as above , when I run it , it pop the error below.

08: value too great for base (error token is "08")


Today is 8th , If I change the date to other date , the problem will not happen , can advise what is wrong ? thx
 
Old 01-08-2009, 02:53 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
A number preceded by 0 in bash is interpreted as an octal number (see the Advanced Bash Scripting Guide, chapter 8.2). So the base is too high for the integer comparison. You can avoid the leading zero using one of the following
Code:
date +%e
date +%_d
in this way the day of the month is padded with spaces and the arithmetic operator returns a decimal numerical constant.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ldasm run error vexer Linux - Software 1 06-09-2009 07:19 AM
Error when trying to Run Frozenbubble WAxlRose Linux - Games 4 02-03-2007 10:50 AM
Unrecoverable Error: execv() error attempting to run powah Red Hat 0 09-06-2006 02:15 PM
error when tying to run python script(bash error?) shanenin Programming 5 01-10-2006 11:01 AM
error message when run MRTG: SNMP error zhgalaxy Linux - Newbie 0 02-18-2004 01:08 PM


All times are GMT -5. The time now is 05:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration