很简单,但能说明白主函数和子函数的实现
#!/bin/bash
square()
{
echo "square of $1 is \c"
echo "$1*$1"|bc
}
########################
cube()
{
echo "cube of $1 is \c"
echo "2^$1"|bc
}
#######################
power()
{
echo "raising 2 to the power of $1 is \c"
}
while getopts s:c:p: option
do
case $option in
s)square $OPTARG;;
c)cube $OPTARG;;
p)power $OPTARG;;
esac
done