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 03-31-2006, 08:26 PM   #1
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Rep: Reputation: 15
Syntax for performing bash simple math calculations


Hi all


I saw this somewhere, but can't remember where... What's the correct syntax for performing simple bash math calculations?

For instance, I just want to dive 105 by 7, what should I write?
 
Old 03-31-2006, 08:50 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Did you mean something like echo $((105 / 7)) or are you thinking of using bc ?
 
Old 03-31-2006, 08:52 PM   #3
stingrayon
LQ Newbie
 
Registered: Mar 2006
Location: DownUnder - Near the Sea
Distribution: FedoraCore
Posts: 2

Rep: Reputation: 0
Try the bc command. It is a powerful calculator available on the command line.


For example you can do the following:

bc <return>
3+4 <return>
7


For a more extensive documentation try "man bc".

---
Stingrayon.
 
Old 03-31-2006, 09:03 PM   #4
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Original Poster
Rep: Reputation: 15
Stingrayon, Homey, thanks alot for your help!
 
  


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
stuck again (noob bash math question) babag Programming 6 04-25-2005 02:27 AM
bash and math division problem bennethos Programming 5 10-17-2004 02:51 PM
Date calculations in BASH script Crashman Programming 4 07-03-2004 11:15 AM
BASH - simple script issue - syntax? tw1ggy5 Programming 11 05-21-2004 10:09 AM
perl - simple array syntax problem lrt2003 Programming 3 05-09-2004 02:35 PM


All times are GMT -5. The time now is 08:46 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration