How to Calculate on a Ubuntu Server


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to Calculate on a Ubuntu Server
# 1  
Old 01-13-2009
How to Calculate on a Ubuntu Server

hi guys. is there a way to calculate numbers and get the accurate results as oppose to the results one gets from using the expr command.

i want to be able to calculate numbers like 1/3 and get the exact results. any help on this is much appreciated. thanks guys

with expr, 1 diveded by 3 = 0

i want something that gives the .33333
# 2  
Old 01-13-2009
one way
Code:
echo "1/3" | bc -l | read result
printf "%f\n" result

# 3  
Old 01-13-2009
Quote:
Originally Posted by jim mcnamara
one way
Code:
echo "1/3" | bc -l | read result
printf "%f\n" result


thanks jim. this code gives a 0.000000. that isn't accurate. is there a way to get the same output one would get from using a calculator?
# 4  
Old 01-13-2009
Yes, it does. Only not in an interactive shell, since bashs read doesn't work there. Use it in a script.
# 5  
Old 01-13-2009
Code:
echo "scale=50 ; 1/3" | bc

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Ubuntu

Backup Ubuntu server 12.05 LT

I wonder what free backup utilities fellow admins are using to clone or backup root disks of ubuntu servers. I try clonezilla, but errors pop up. Any ideas? ---------- Post updated at 02:51 PM ---------- Previous update was at 09:49 AM ---------- I have used the rsync command like: rsync... (0 Replies)
Discussion started by: fretagi
0 Replies

2. Ubuntu

Ubuntu Server in VM - DHCP Server not working

Hello. Doing my first steps in Linux and while trying to configure a DHCP server in Linux i encountered some problems: TOPOLOGY: - Laptop with Windows 8.1 - VM Player 12 with Linux installed (Ubuntu Server 14.04) - ICS-DHCP-SERVER installed and running - Another LAPTOP conected to a... (1 Reply)
Discussion started by: Portuguevos
1 Replies

3. Solaris

How to calculate the number of TPS on Solaris server?

Hi, Please help me to find how to calculate the number of TPS supported by any solaris server for example one server with below configuration . Sun Blade X6270 with two 4-core processors 2 x 300 GB internal disk drives (2 Replies)
Discussion started by: manojkakkar
2 Replies

4. UNIX for Dummies Questions & Answers

Help with Ubuntu server 12.04 installation

hello, i have been try installing Ubuntu server 12.04 and receiving a message: no network interface card detected. can someone help me to locate where my interface card is (1 Reply)
Discussion started by: naghazky
1 Replies

5. Ubuntu

Set up a Ubuntu server as a FTP server

Hello, How can I set up a ubuntu server as a FTP server? Thanks, (1 Reply)
Discussion started by: Pouchie1
1 Replies

6. Ubuntu

Ubuntu Server

Hi, My problem is that I need to set up a DNS server and a mail server. I just know that IP address of the server we have rented. Can you tell me if I can set up mail server and a DNS server with just the IP address? Tushar (6 Replies)
Discussion started by: tusharkumar
6 Replies

7. Ubuntu

Can Ubuntu be used as a decent server?

Can Ubuntu be used as a decent server? Say a web server, a file server, or a mail server? Also, does Ubuntu play nice with virtualbox? Or should I use another brand of Linux to accomplish these things? (3 Replies)
Discussion started by: jastanle84
3 Replies

8. UNIX for Dummies Questions & Answers

Would like to install x86 desktop Ubuntu over AMD64 Ubuntu server

My intention was to build a dual boot XP Pro 64 and Ubuntu media server. I had installed the AMD64 version of Ubuntu 8.10 server and thought that I would be able to install Apache server. I need a GUI to work in. I tried to boot and install Mythbuntu 32 bit 8.10, but my machine now won't recognize... (0 Replies)
Discussion started by: docflyboy
0 Replies

9. Shell Programming and Scripting

calculate server uptime in % (99.98), using ksh script

Let me preface by saying, I have looked through many threads that deal with keep the decimal, however I'm not sure that any one resolution meets my needs, ok, ok, they could. So maybe it's just that I am not understanding the resolution - therefore I am posting a new thread. myknowledgebase=at... (2 Replies)
Discussion started by: cml2008
2 Replies
Login or Register to Ask a Question