LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-06-2007, 09:31 PM   #1
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Rep: Reputation: 15
Shell Scripting


hey guyz,
i need to do computation using decimal places..
any idea how to do it within a shell script?
 
Old 11-06-2007, 09:48 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
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/
 
Old 11-06-2007, 10:05 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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)
 
Old 11-06-2007, 11:59 PM   #4
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
i need to get my data from a loop..
so how do i show it?
i don't understand how to use the formula..
 
Old 11-07-2007, 01:21 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Quote:
Originally Posted by ryanlum View Post
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.
 
Old 11-07-2007, 06:01 AM   #6
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
Shell Scripting Help Elguapo Programming 1 09-07-2006 07:03 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
shell scripting Prasun1 Linux - General 1 06-23-2005 07:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration