Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
#!/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
./process.sh 5
意思是“$价值”,因此$f被评估为字符串文字1。所以...
$
$f
1
$f=$(($c*$f)) $c=$(($c-1))
应该
f=$(($c*$f)) c=$(($c-1))
在循环中,它应该是