#!/bin/bash
square()
{
echo "Please input the num:"
read num1
let "squ=num1*num1"
echo "Square of $num1 is $squ"
}
cube()
{
echo "Please input the num:"
read num2
let "c=num2*num2*num2"
echo "Cube of $num2 is $c"
}
power()
{
echo "Please input the num:"
read num3
echo "Please input the power:"
read p
let "temp=1"
for(( i=1;i<=$p;i++ ))
do
let "temp=temp*num3"
done
echo "power $p of $num3 is $temp."
}
choice()
{
select i in "square" "Cube" "Power"
do
break;
done
echo "you select is $i"
case $i in
square)
square
;;
Cube)
cube
;;
Power)
power
;;
*)
echo "select item is not exist"
esac
}
choice
shell 练习(function,case,for,select)
最新推荐文章于 2021-06-24 11:44:23 发布