LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Shell Scripting (https://www.linuxquestions.org/questions/linux-general-1/shell-scripting-597661/)

ryanlum 11-06-2007 09:31 PM

Shell Scripting
 
hey guyz,
i need to do computation using decimal places..
any idea how to do it within a shell script?

Simon Bridge 11-06-2007 09:48 PM

Novell have a neat solution using bc and a small script:
http://www.novell.com/coolsolutions/tools/17043.html

This one uses awk:
http://www.linuxquestions.org/questi...t-math-401093/

pixellany 11-06-2007 10:05 PM

Python is good at math, including floating point. Shells (at least BASH) were never intended for such things.

(Not suggesting that Simon's suggestions won't work)

ryanlum 11-06-2007 11:59 PM

i need to get my data from a loop..
so how do i show it?
i don't understand how to use the formula..

Disillusionist 11-07-2007 01:21 AM

Quote:

Originally Posted by ryanlum (Post 2950681)
i need to get my data from a loop..
so how do i show it?
i don't understand how to use the formula..

Post what you have so far, this will help us see where you are getting stuck.

Please put code tags around your code by highlighting the code and pressing the # icon shown in post area directly above the test entry section.

Simon Bridge 11-07-2007 06:01 AM

Quote:

(Not suggesting that Simon's suggestions won't work)
Not that they arn't shameless hacks :) Not actually knowing what the computation is for, and suspecting "homework", suggests I should just point. One could use octave with an m-file for instance.

Looks like ryanlum wants to repeat a calculation lots of times with an output each time. One would normally write the data to something nyet? Some sort of data structure, an array, a variable, or a text file. What is chosen depends on what one wants to do with the data afterwards.

Disillusionist is right: time to show code.


All times are GMT -5. The time now is 04:10 PM.