Issue
The program takes input but show the following errors, how to resolve those errors ?
Solution
I think you need to add a space after [
and before ]
:
#!/bin/bash
echo "Enter the number to find it's factorial"
read number
total=1
counter=1
while [ $counter -le $number ];
do
total=` expr $counter \* $total`
counter=` expr $counter + 1`
done
echo $total
Working here on Ubuntu:
$ ./factorial.sh
Enter the number to find it's factorial
5
120
Answered By - Jardel Lucca