loader image

Shell script to find mean and standard deviation

Aim : Write a shell script to find mean and standard deviation of three numbers

#!/bin/bash
echo "Enter three integers with space between"
read a b c
sum=`expr $a + $b + $c`
mean=`expr $sum / 3`
aa=$((($a - $mean) * ($a - $mean)))
bb=$((($b - $mean) * ($b - $mean)))
cc=$((($c - $mean) * ($c - $mean)))
sd=$( echo "sqrt(($aa + $bb + $cc) / 3)" | bc -l )
echo "sum=$sum"
echo "mean=$mean"
echo "Sd=$sd"
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Nasra

It’s Nice! Great!