shell裡邊子函式與主函式的例項(轉)

ba發表於2007-08-12
shell裡邊子函式與主函式的例項(轉)[@more@]很簡單,但能說明白主函式和子函式的實現
#!/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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617731/viewspace-950287/,如需轉載,請註明出處,否則將追究法律責任。

相關文章