#!/bin/bash f=1 c=$1 while [[ $c != 0 ]] do $f=$(($c*$f)) $c=$(($c-1)) done echo $c
我不断收到错误
./process.sh: line 8: 1=0: command not found ./process.sh: line 7: 5=5: command not found
运行./process.sh 5
$
意思是“价值”所以$f
得到评估字符串文字1
。 所以…
$f=$(($c*$f)) $c=$(($c-1))
应该
f=$(($c*$f)) c=$(($c-1))
在循环中,应该是
f=$(($c*$f)) c=$(($c-1))