$cat factorial.sh
#!/bin/bashecho “Please input number:”
read n
result=1
i=1
while[$i -le $n]do
result=`expr $i\*$result`
i=`expr $i+1`doneecho “The result is :$result!”
$./factorial.sh
Please input number:
$
The result is :120!
设计一个shell程序计算n的阶乘,要求:(1)从命令行接收参数n;(2)最后输出计算的结果。$cat factorial.sh#!/bin/bashecho “Please input number:”read nresult=1i=1while[$i -le $n]do result=`expr $i\*$result` i=`expr $i+1`doneecho “The result is :$result!”$./factorial.shPlease input n