Length conversion using shell coderinme

length conversion using shell

As you have learned some thing about shell in previous post leap year
so let’s do it again
code to learn length conversion using shell
Convert the distance from Km into cm ,m , inch & feet

#!/bin/bash
(bash copy)
read -p "Enter the distance between two cities (in km): " dist
meters=`expr $dist \* 1000`
centimeter=`expr $dist \* 100000`
feet=`bc <<< "scale=2;$dist * 3280.84"`
inch=`bc <<< "scale=2;$dist * 39370.1"`
echo "(in meters): $meters"
echo "Distance converted (in feet): $feet"
echo "(in inch): $inch"
echo "Distance converted (in centimeter): $centimeter"

Leave a reply:

Your email address will not be published.