I am trying to write a shell script that takes an unspecified no. of command line arguments upto 9 and finds their sum. The number should be added to sum only if it is greater than 10. The code that I have tried is
#!/bin/sh
sum=0
for i in $@
do
if [$i -gt 10]
then
sum=$((sum+i))
else
continue
fi
done
echo $sum
But I am getting the following error when I try to execute
xyz@LAPTOP-1NOBF8F8:~$ vi Sum2.sh
xyz@LAPTOP-1NOBF8F8:~$ chmod +x Sum2.sh
xyz@LAPTOP-1NOBF8F8:~$ ./Sum2.sh 19 5 3
./Sum2.sh: 5: [19: not found
./Sum2.sh: 5: [5: not found
./Sum2.sh: 5: [3: not found
0
Please let me know what am I missing .