In this post i am going to explain various ways to arithmetic calculation in linux. Their are three commands to do arithmetic calculation. They are
1.bc,
2.let and
3.expr.

 

arth 300x249 Arthimetic operators commands in linux

bc:

To subtract two number
#echo 6000-5816 | bc

To add two numbers
#echo 6000+5000 | bc

Using bc command we can add two variables
#c=15 ; d=25 ; echo $c+$d | bc

Command to multiply two numbers
#echo 5*5 | bc

Command to divide two numbers
#echo 5/5 | bc

Command to modulo
#echo 48%5 | bc

let:

let command to add two numbers
#let a=5+6 ; echo $a

let command to subtract two numbers
#let a=36-6 ; echo $a

let command to multiply two numbers
#let a=5*6 ; echo $a

let command to divide two numbers
#let a=36/6 ; echo $a

expr :

Note:Use man expr for more details

To add and display the result
#expr 5 + 6

To delete and display the result
#expr 5 – 3

To Divide and display the result
#expr 25 / 5

To do modulo
#expr 25 % 3

Share and Enjoy

  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
  • wp socializer sprite mask 32px Arthimetic operators commands in linux
© Copyright 2012-2013 Thetechnicalstuff. All rights reserved. Reproduction without written permission is prohibited.

About Us | Copyright | Privacy Policy | Contact Us