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
Value Too Great For Base (error Token Is 0008 )
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question value too great for base (error token is 008 ) 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;
Value Too Great For Base Date
it only takes a minute: Sign up Bash error: value too great for base (error token is “09”) up vote 11 down vote favorite 1 When running this part of my bash script am getting an error Script value=0 for bash associative array value too great for base (( t=0; t <= 4; t++ )) do d1=${filedates[$t]} d2=${filedates[$t+1]} ((diff_sec=d2-d1)) SEC=$diff_sec compare=$((${SEC}/(60*60*24))) value=$((value+compare)) done Output jad.sh: line 28: ((: 10#2014-01-09: value too great for base (error token is "09") jad.sh: line 30: /(60*60*24): syntax error: operand expected (error token is "/(60*60*24)") d1 and d2 are dates in that form 2014-01-09 and 2014-01-10 Any solution please? bash share|improve this question asked Jan 10 '14 at 16:45 user3178889 66127 1 You can't just subtract dates in the form YYYY-MM-DD. You bash base 10\ have to convert them to plain numbers first, like time_t timestamps (which will get you seconds). –Mark Reed Jan 10 '14 at 16:47 2 Looks like it's converting your 09 to octal notation, so chances are it's actually trying to compute 2014 - 1 - 9, but since 09 is not a valid number (the 0 at the front means use octal instead of decimal) it's complaining. –robbrit Jan 10 '14 at 16:49 what the solution robbirt? –user3178889 Jan 10 '14 at 16:59 add a comment| 4 Answers 4 active oldest votes up vote 23 down vote accepted Prepend the string "10#" to the front of your variables. That forces bash to treat them as decimal, even though the leading zero would normally make them octal. share|improve this answer answered Jan 10 '14 at 17:07 rojomoke 1,382617 add a comment| up vote 5 down vote What are d1 and d2? Are they dates or seconds? Generally, this error occurs if you are trying to do arithmetic with numbers containing a zero-prefix e.g. 09. Example: $ echo $((09+1)) -bash: 09: value too great for base (error token is "09") In order to perform arithmetic with 0-prefixed numbers you need to tell bash to use base-10 by specifying 10#: $ echo $((10#09+1)) 10 share|improve this answer answered Jan 10 '14 at 17:05 dogbane 137k42236323 1 if i have a variable holding $date=2014-01-09 using 10# won
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 policies of this site About Us Learn more about Stack Overflow the company
Bash Force Base 10
Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags bash remove leading zeros Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only
Bash Array Value Too Great For Base
takes a minute: Sign up Here's how it works: Anybody can ask 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 http://stackoverflow.com/questions/21049822/bash-error-value-too-great-for-base-error-token-is-09 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 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♦ 42.1k686153 asked May 9 at 11:03 EmberSpirit 172 3 http://askubuntu.com/questions/769722/bash-12-08-value-too-great-for-base-error-token-08 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 43.8k780134 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 there :) Have a look at man bash | grep '#'. –terdon♦ May 9 at 16:01 @cat: # only starts a comment when used at the beginning of a word. –deltab May 9 at 16:31 At the beginning of a word; e.g. echo foo#bar #baz will output foo#bar but not #baz, because the latter starts a comment. –deltab May 9 at 19:52 add a comment| Your Answer draft saved draft discarded Sign up or log i
Post your question and get tips & solutions from a community of 418,546 IT Pros & Developers. It's quick & easy. Why 08, 09 cannot be used as 8 ,9? P: 8 arthurzzk If you do $((08+1)) or https://bytes.com/topic/unix/answers/605323-why-08-09-cannot-used-8-9-a $((09+1)) in terminal, linux shows an error. However, you can use 07,06,05,04,03,02,01,00, and Linux treat them as http://unix.stackexchange.com/questions/185042/value-too-great-for-base-error-token-is-08 7,6,5,4,3,2,1,0. Can someone tell me how to make 08 and 09 work in this way? Feb 20 '07 #1 Post Reply Share this Question 6 Replies Expert 2.5K+ P: 3,235 Motoma If you do $((08+1)) or $((09+1)) in terminal, linux shows an error. However, you can use 07,06,05,04,03,02,01,00, and Linux treat them as 7,6,5,4,3,2,1,0. Can someone tell me how to make 08 and 09 work in this value too way? That's easy! Prefacing a number with a 0 when it isn't the only digit before a decimal (.) will cause most programming languages to treat is as Octal (base 8). The highest numeric digit in octal is 7, thus 8 and 9 will not show up. If you don't believe me, try 077 and see what you get. Feb 21 '07 #2 reply P: 8 arthurzzk can someone tell me how to make 08 and 09 work as 8, 9? Feb 21 '07 #3 value too great reply Expert 2.5K+ P: 3,235 Motoma can someone tell me how to make 08 and 09 work as 8, 9? As far as I know, this cannot be done in the way you've posed the question. This is similar to asking for 0x11 be represented as 11 (which is certainly not the case). Feb 21 '07 #4 reply P: 8 ValHolla if you need them to be viewed as 08 and 09 you can do your calculations with the decimal equivalents 0 - 9 and use printf to display them with the leading 0 (zero) Apr 27 '07 #5 reply Expert 100+ P: 534 michaelb This behavior seems to vary depending on the shell: Expand|Select|Wrap|Line Numbers ~>echo$SHELL /usr/local/bin/bash ~>echo$((09+7)) -bash:09:valuetoogreatforbase(errortokenis"09") ~>ksh $echo$((09+7)) 16 $ There's also the typeset built-in which can be used for formatting: Expand|Select|Wrap|Line Numbers $ $typeset-Z2num1=9 $typeset-Z3num2 $num2=8 $echo$num1 09 $echo$num2 008 $echo$((num1*num2)) 72 $ Apr 27 '07 #6 reply P: 1 shamrockjade This worked for me in the bash shell. If I tried to default the dirNUM to 3 digits first then I would error out with the 08 errors. Expand|Select|Wrap|Line Numbers dirNUM=1 until[[$dirNUM==367]] do #Changedirectorynumberto3digits if[[!-d${root_dir}/$(printf"%.3d"$dirNUM)]] then mkdir${root_dir}/$(printf"%.3d"$dirNUM) fi ((dirNUM+=1)) done Dec 21 '09 #7 reply Message Cancel Changes Post your reply Join Now >> Sign in to post your reply or Sign up for a free account. Similar topics Cannot delete X: It is being used by another person or program. Cannot Create/Shadow Copy Error Compiler executable file c:\..\v1.1.4322\csc.exe cannot be fou
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 posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top value too great for base (error token is “08”) up vote 1 down vote favorite Trying to do quiz 'max sum of 2 from grid' Can't figure out how to get around the error below. Feels like I'm missing something. Once I find out what I can update the question to be more general and applicable to others perhaps. Line 32: value too great for base (error token is "08") #!/bin/bash setup () { grid=(01 02 03 04 05 06 07 08 07 06 05 12 13 14 15 16 15 14 13 12 11 11 05 06 06 07 07 07 06 06 05 05 04) n=${#grid[@]} number_of_lines=$((n / 11)) length_of_line=$1 largest_sum=0 largest_pos=0 } largest_2 () { for ((row=0; row < number_of_lines; row++)) { for ((column=0; column