Bash Value Too Great For Base Error Token Is 08
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or value too great for base error token is 09 linux posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss value too great for base (error token is 008 ) Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes value too great for base (error token is 0008 ) a minute: Sign up Shell Script Error: Value too great for base (error token is “08”) [duplicate] up vote 16 down vote favorite 1 This question already has an answer here: Bash error: value too great for base (error token value too great for base date is “09”) 4 answers Here my problem is to find the difference of using single bracket [ ] and double brackets [[ ]] in if statement. #!/bin/bash vara=08; varb=10; ## single bracket in if statment is working. if [ $vara -lt $varb ]; then echo "yes"; else echo "no"; fi ## double brackets in if statment is not working; throwing an error like below. ## [[: 08: value too great for base (error token is "08") if [[ $vara -lt $varb
Bash Associative Array Value Too Great For Base
]]; then echo "yes"; else echo "no"; fi bash shell share|improve this question asked Jul 16 '14 at 9:49 Thaangaraj 1551110 marked as duplicate by Charles Duffybash Users with the bash badge can single-handedly close bash questions as duplicates and reopen them as needed. May 11 at 21:40 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. add a comment| 1 Answer 1 active oldest votes up vote 29 down vote accepted The shell tries to interpret 08 as an octal number, as it starts with a zero. Only digits 0-7 are, however, allowed in octal, as decimal 8 is octal 010. Hence 08 is not a valid number, and that's the reason for the error. Single brackets are kind of "compatibility mode" with sh, and sh does not know about octal numbers. So, if you use single square brackets, "010" will be interpreted as 10, while with double square brackets, "010" will be interpreted as 8. If you use single square brackets, "08" will be interpreted as 8, while with double square brackets, it is not a valid number and leads to an error. You can avoid the error by using the solution described here: http://stackoverflow.com/a/12821845/1419315 if [[ ${vara#0} -lt ${varb#0} ]] or if [[ $((10#$vara)) -lt $((10#$varb)) ]] share|improve this answer edited May 11 at 19:18 answered Jul 16 '14 at 9:52 JohnB 6,
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Bash Base 10\
policies of this site About Us Learn more about Stack Overflow the bash force base 10 company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges Unanswered value too great for base hex Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask http://stackoverflow.com/questions/24777597/shell-script-error-value-too-great-for-base-error-token-is-08 a question Anybody can answer The best answers are voted up and rise to the top Bash 12 - 08 Value too great for base (error token “08”) up vote 2 down vote favorite So, I'm trying to calculate 12-08 (not 12-8) and get the following error: let: 08: value too great for base (error token is "08") Here's the sample code: first=12 http://askubuntu.com/questions/769722/bash-12-08-value-too-great-for-base-error-token-08 second=08 if [[ ($first > $second) ]]; then let fin=first-second else let fin=second-first fi P.S Sorry about the spacings bash scripts share|improve this question edited May 9 at 11:15 terdon♦ 41.5k685150 asked May 9 at 11:03 EmberSpirit 172 3 See Why does bash thinks that 010 is 8? –steeldriver May 9 at 11:11 add a comment| 1 Answer 1 active oldest votes up vote 7 down vote If you precede a number by 0, bash treats the number as octal. As octal is base 8 with digits ranging from 0 to 7, 08 is out of range for octal. Now you have two options to do decimal calculation: Omit preceding 0: $ echo $(( 12 - 8 )) 4 Explicitly mention base as decimal by 10#: $ echo $(( 12 - 10#08 )) 4 share|improve this answer edited May 9 at 15:14 Community♦ 1 answered May 9 at 11:11 heemayl 42.3k776129 2 @cat it's also used in i) the shebang line (#!/bin/bash); ii) string manipulation (var="foo"; echo ${var#f}); iii) the $# variable; iv) the !# variable and a few other fringe cases here and
HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie [SOLVED] bash error as [[: 08: value too great for base (error token is "08") User Name Remember Me? Password Linux - http://www.linuxquestions.org/questions/linux-newbie-8/bash-error-as-%5B%5B-08-value-too-great-for-base-error-token-is-08-a-4175465153/ 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 Welcome to LinuxQuestions.org, a http://www.getshifting.com/wiki/fixscriptvaluetoogreatforbase friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other value too special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? value too great Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread 06-07-2013, 03:32 PM #1 cli Member Registered: Apr 2013 Distribution: RedHat, Cent, Ubuntu Posts: 80 Rep: 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 #!/bin/bash Today_Date=$(date '+%d') Today_Week=$(date '+%w') if [[ $Today_Date -ne 1 || $Today_Week -gt 0 ]]; then echo "Today is neither month 1st, nor sunday." fi
Script: Value Too Great For Base Sidebar Sponsor: Would you like to sponsor this site? Or buy me a beer?: Recently Changed Pages: View All Pages View All Q Pages ad admt aix apache backup blog bordermanager cisco cloud config dutch edirectory email fiber fix gpo groupwise hardware idm install itmanagement law ldap linux mssql myown netapp netware network notes oracle performance phones redhat scripts security software solaris srm storage syslog tomcat tools tscitrix unfinished vmware websphere wiki windows zenworks View All Tags Sign up for Q to post comments. WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you. Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer. Terms And Conditions for Q users Pages with comments View All Comments wiki fixscriptvaluetoogreatforbase Fix: Script: Value Too Great For Base ./script.sh: line 101: [[: 09: value too great for base (error token is "09") The error occurs when you have a integer value that start with a “0” (zero). Bash will interpret that as an octal, which means 08 and 09 are invalid. I got the error by setting the hour in an variable and making an comparison on it: hour=`date +%H` You can force bash to read the number as a decimal by putting “10#” in front of it: hour="10#`date +%H`" That fixed it. fix, scripts You could leave a comment if you were logged in. fixscriptvaluetoogreatforbase.txt · Last modified: 2013/04/21 10:08 by sjoerd Page Tools Show pagesourceOld revisionsBacklinksBack to top Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License