Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Help with this code (http://www.programmingforums.org/showthread.php?t=12803)

Silicon_Pudding Mar 15th, 2007 1:41 AM

Help with this code
 
:

ITERATE=240
for COUNT in `seq -w 1 $TOTAL`
do
  OTHER=$(($COUNT*2))
  ... more stuff
  ...
done

The problem I am having is that I can't figure out how to multiply COUNT by 2. In this example since TOTAL is 240, COUNT will be 3 digits. I get an error message at count 8 saying the value is too great for the base, which I assume is because of 3 digits and something with binary.

Is there a way I can multiply this number by two, while still interating through by one?

a thing Mar 15th, 2007 3:55 PM

Don't use the -w option on seq. Many things interpret numbers starting with 0 as octal (base 8), likewise with 0x and hexadecimal (base 16).

Silicon_Pudding Mar 15th, 2007 4:45 PM

I need the -w option to keep the 000 spaces in front of the number. Is there another clean way to do this?

Serinth Mar 17th, 2007 12:20 PM

try this:
previously declare variable OTHER and set it to 0 then in the loop:
:

let OTHER="$COUNT"*2


All times are GMT -5. The time now is 9:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC