Bash Value Too Great For Base Error Token Is 0008
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 value too great for base error token is 09 linux this site About Us Learn more about Stack Overflow the company Business
Bash Value Too Great For Base 08
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask value too great for base (error token is 09 ) Question x Dismiss 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 a minute: Sign up
Value Too Great For Base Date
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 is “09”) 4 answers Here my problem is to find the difference of using single bracket [ ] and double brackets [[ ]] in if statement. #!/bin/bash bash associative array value too great for base 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 ]]; 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. Sing
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs:
Bash Base 10\
Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO
Bash Force Base 10
login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] value too great for base -bash Having an value too great for base (error token is 008 ) Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, thanks ! Results 1 to 9 of 9 Thread: [SOLVED] value too great for base -bash Thread Tools Show Printable http://stackoverflow.com/questions/24777597/shell-script-error-value-too-great-for-base-error-token-is-08 Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode January 25th, 2008 #1 sagarhshah View Profile View Forum Posts Private Message A Carafe of Ubuntu Join Date May 2006 Location Mombasa, Kenya Beans 82 DistroUbuntu 10.04 Lucid Lynx [SOLVED] value too great for base -bash Hi, I am writing a script in bash. Everything works fine well almost!! I am only having one problem whenever this part of the script Code: if [ $((items)) -eq 0 https://ubuntuforums.org/showthread.php?t=677751 ] ; then comes across a 08 or 09 it throws an error "value too great for base (error token is "09")" I read up on it and apparently it seems to think 08 or 09 are hex nos or something to that effect. I can't replace the 0's as I need them for later on in the script. does anybody have a workaround to this? any help would be appreciated thanks sagar Life's a journey. Enjoy the ride!! Adv Reply January 25th, 2008 #2 colo View Profile View Forum Posts Private Message Visit Homepage Frothy Coffee! Join Date Apr 2005 Location Austria Beans 246 DistroKubuntu Re: value too great for base -bash Why are you using an arithmetical expression in there ( "$((value))" instead of "${value}"? The error message is, however, quite easily explained. Numerical values starting with a zero (0) are interpreted as numbers in octal notation by the C language. As the only digits allowed in octal are {0..7}, an 8 or a 9 will cause the evaluation to fail. Hth, - colo johannes.truschnigg.info - meine Website. Adv Reply January 25th, 2008 #3 sagarhshah View Profile View Forum Posts Private Message A Carafe of Ubuntu Join Date May 2006 Location Mombasa, Kenya Beans 82 DistroUbuntu 10.04 Lucid Lynx Re: value too great for base -bash The double brackets were my bad. Am new to shell scripting. ok so numbers that start with 0 are thought of as octal or base 8
is "0008") Date: Wed, 4 Nov 2009 08:23:08 -0500 User-agent: Mutt/1.4.2.3i On Tue, Nov 03, 2009 at 05:37:45PM -0700, Bob Proulx wrote: > Dobromir Romankiewicz wrote: > > bash: 0008: value too great for base (error token is https://lists.gnu.org/archive/html/bug-bash/2009-11/msg00009.html "0008"). > Numbers with leading zeros are read as octal constants. Octal is > http://www.tek-tips.com/viewthread.cfm?qid=1133283 composed of '0' through '7'. The number '8' is too large to be an > octal number. > > $ echo $((0008)) > bash: 0008: value too great for base (error token is "0008") > > To have the number read as a decimal number the leading zeros must be > removed. > > $ echo value too $((8)) > 8 If removing the leading zeroes would be difficult for you, then you can force the arithmetic expression to use base 10 by prefixing the variable with "10#". Thus: month=$(date +%m) # Can produce "08" etc. next_month=$(( (10#$month == 12) ? 1 : 10#$month+1 )) echo $next_month On the other hand, removing a single leading zero is not difficult: month=$(date +%m) month=${month#0} # Removing leading 0 next_month=$(( ($month == value too great 12) ? 1 : $month+1 )) Removing multiple leading zeroes, however, requires either a loop, or the use of extended globs. A variant of this question (removing leading/trailing spaces) appears at
Join INTELLIGENT WORK FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Linux (server) Forum at Tek-Tips HomeForumsMIS/ITOperating Systems - UNIX basedLinux (server) Forum shell script - pls help thread54-1133283 Forum Search FAQs Links MVPs shell script - pls help shell script - pls help santanudas (TechnicalUser) (OP) 6 Oct 05 12:06 hi guys,Need to write a bash script which will increment the numbers by 1 but the number should be with leading zero, i.e. 01, 02, 03 etc.So, if I do#!/bin/bashs=`seq -w 5 12`for i in $sdoecho $[i+1]done not returning the desired result. I tried replacing“$[i+1]” with “$[s+1]” and that doesn't work too. What wrong am I doing? Any guys out here to help?Thanks in advance. RE: shell script - pls help thedaver (IS/IT--Management) 6 Oct 05 14:09 Why not just write the "for" using 01 02 03 04 05 06 ....? D.E.R. Management - IT Project Management Consultinghttp://www.dermanagement.com/ RE: shell script - pls help ericbrunson (TechnicalUser) 6 Oct 05 14:26 You're going to run into a problem, since bash interprets numbers with a leading zeor as octal, so when you try to do 08, you'll get an error because it's not a valid number.Other than that, you could use 'printf "%02d\n" $[i+1]' to get your formatting.You'll have to strip off the leading zeros before you do the addition. RE: shell script - pls help santanudas (TechnicalUser) (OP) 6 Oct 05 17:01 thedaver, `seq 5 12` was just an example. Actually what I’m doing is:r=`ls /some-dir/ | wc -l`s=`seq -w 1 ${r}`so, I know the number. Right now it’s 57; no wonder if it gets 200 tomorrow or the day after. And as dfdf says, I figured out still I’m in trouble even if I do like 01, 02, 03……ericbruns