0 Shares 1793 Views 1 Comments
00:00:00
21 Jul

Fix “bc command not found” on Linux/CentOS for floating point arithmetic

Oliver Krautscheid Oct 17, 2014
0 1794 1

The other day I wanted to perform some calculations via bash, but ended up getting an error “invalid arithmetic operator”. Here’s what you can do.


Bash and floating point arithmetic

Bash does not support floating point calculations. In order to calculate decimal numbers we are going to use the command bc. Bc stands for bench calculator or basic calculator and is the go-to language for calculating stuff when you’re on a Linux distribution such as CentOS.

Whenever you try to do a floating point calculation in bash you will get the error:

invalid arithmetic operator (error token is ...)

Installing BC

By default BC is not installed on CentOS, so we are going to install it

yum install bc

If you get the error PYCURL ERROR 22, you find the fix here

Installing Bc On Centos 6 5.Png

That’s it – bc is now installed and you should be good to go.

About Us

Webmaster .Net is your all-in-one resource for blogging tips, system administration guides, industry news and a growing community of webmasters.

Can't find something or want to tip us?Contact@webmaster.net

Bulls and Bears
  • iffitheking

    Thanks a lot !!

Webmaster Tutorials, Wordpress
0 shares665 views

WordPress SQL Query: Select And Delete Posts Between Two Dates

Oliver Krautscheid - Apr 08, 2017

If you are wondering how to delete posts for a certain date, you will need to know how Wordpress stores…

Advertising and Ad Networks, Copywriting
0 shares810 views

15 Tips For Increasing Facebook Ads CTR – Full Guide [2017 Update]

Cam Connor - Mar 30, 2017

In this article, we'll talk a lot about how you can write quality text ads on Facebook Ads to get…

Webmaster Tutorials
0 shares1528 views

10 Steps To Configure Nginx For WordPress, Drop Varnish And Cut Your CPU Load By 50%

Oliver Krautscheid - Oct 10, 2016

Are you using Varnish on your Wordpress blog? Possibly the Varnish script by Unixy? Great! Get rid off it. Here's…

Follow Us And get latest news

© 2016 Webmaster.Net - Property of Peakstone Media Ltd. - All rights reserved. | Privacy Policy | DMCA | Contact Us | Advertise