Sunday, February 5, 2012

Arithmetic Operators in Shell Script


Here are Some Arithmetic Operators Used in Shell Script.


OPERATOR DESCRIPTION
+ Add two Numbers
- Subtract two Numbers
* Multiply two Numbers
/ Division
% Modulus
= Assignment

Example
#!/bin/bash

a=5
echo -e "value of a is $a\n"

echo -e "assigning value of a to b\n"
b=$a
echo -e "value of b is $b\n"

echo -e "adding two number\n"
echo `expr $a + $b`
echo " "

echo -e "

0 comments:

Post a Comment