Reputation: 16092
#!/bin/bash
f=1
c=$1
while [[ $c != 0 ]]
do
$f=$(($c*$f))
$c=$(($c-1))
done
echo $c
I keep getting the error
./process.sh: line 8: 1=0: command not found
./process.sh: line 7: 5=5: command not found
When running ./process.sh 5
Upvotes: 2
Views: 108
Reputation: 53496
The $
means "value of" so $f
gets evaluated to the string literal 1
. So...
$f=$(($c*$f))
$c=$(($c-1))
should be
f=$(($c*$f))
c=$(($c-1))
Upvotes: 5