Linux Value Too Great For Base Error Token Is
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 posting value too great for base (error token is 0008 ) ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Value Too Great For Base Date
the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a bash associative array value too great for base 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 is “09”) value too great for base (error token is 008 ) 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 ]]; then echo
Bash Base 10\
"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 30 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,80911645 thank you
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings bash force base 10 and policies of this site About Us Learn more about Stack Overflow bash array value too great for base the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Bash Remove Leading Zeros
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/24777597/shell-script-error-value-too-great-for-base-error-token-is-08 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 (( 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: http://stackoverflow.com/questions/21049822/bash-error-value-too-great-for-base-error-token-is-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 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 d
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 http://unix.stackexchange.com/questions/185042/value-too-great-for-base-error-token-is-08 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 & http://www.gchandra.com/linux/error-bash-08-value-too-great-for-base-error-token-is-08.html 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 value too 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 value too great 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 is "08") or bash: 09: value too great for base (error token is "09") This error message is seen when an arithmetic operation is performed on numbers which has value 08 or 09. Mostly when dealing with months and days. Reason : As the number start with 0, linux assumes it as number with Octal base and since there are no 8 and 9 in octal it throws the above error. Solution : Convert the number 08 to 8, do the arithmetic operation and later convert it back if needed. Example : $ mm=08 #Converting 08 to 8 $ mm1=$(echo $mm| awk ‘{printf "%d\n",$0;}') $ echo $mm1 # Adding 1 to 8 $mm1=$(($mm1+1)) $ echo $mm1 # Converting 9 to 09 $mm2=$(printf %02d $mm1) $echo $mm2 09 Categories: Linux | Tags: base, Bash, error token, Linux, octal | Permalink Leave a Reply Cancel reply Required fields are marked *.Message *Name * Email * Website you MUST enable javascript to be able to comment Notify me of follow-up comments by email. Notify me of new posts by email. ← Previous Post Next Post → Free WP Plugin Delete All Comments Recent Scripts Hive : Create database in different folder Linux : Compress entire folder to .gz or .bz2 Error : bash: 08: value too great for base (error token is "08") Linux Tip : Convert date time to Unix Time (Epoch) Linux Tip : Split Date into Day, Month, Year Hive Error : SemanticException TOK_ALLCOLREF Linux : Split Name and Extension from filename SQLServer : Get Last Businessday of previous month Special or Random characters on PuTTy screen How to kill or terminate a frozen windows task manager Older Scripts August 2015(7) September 2014(1) August 2014(1) March 2014(1) December 2013(1) August 2013(1) March 2013(2) October 2012(4) May 2011(1) February 2011(1) December 2010(4) October 2010(1) August 2010(1) May 2010(3) June 2009(2) May 2009(3) April 2009(3) March 2009(1) February 2009(1) January 2009(1) December 2008(2) October 2008(7) September 200