Add, Subtract, Multiply, Divide Shell Script

All Scripts written under Ubuntu 7.04

Add

#!/bin/bashread -p "x:" x

read -p "y:" y

echo -n "$x+$y="

echo "scale=4; $x + $y" | bc

Subtract


#!/bin/bashread -p "x:" x

read -p "y:" y

echo -n "$x-$y="

echo "scale=4; $x - $y" | bc

Multiply


#!/bin/bashread -p "x:" x

read -p "y:" y

echo -n "$x*$y="

echo "scale=4; $x * $y" | bc

Divide


#!/bin/bashread -p "x:" x

read -p "y:" y

echo -n "$x/$y="

echo "scale=4; $x / $y" | bc

~ by aric on July 27, 2007.

2 Responses to “Add, Subtract, Multiply, Divide Shell Script”

  1. toluifera welcome deota squirearchy batavi circumspangle sermonizer rhinophyma
    Economy Heating & Air Conditioning, Inc.
    http://www.thediamondboutique.co.nz

    馬祖餐廳

  2. Well done bro,
    This post helped me getting some script to work as supposed.

    I think you maybe need to do some more clarification for beginners.

    Thanks again for this post..
    Keep up the good thing..

    Regards..

Leave a Reply