Reputation: 458
I'm getting the error:
ex02.sh: line 6: syntax error near unexpected token `elif'
ex02.sh: line 6: `elif [ #$ -gt 1 ] ; then'
My script:
#!/bin/bash
if [ #$ -le 1 ] ; then
echo 'usage: ex02.sh max|min|sum v2 [v2 ...]'
exit 1
elif [ #$ -gt 1 ] ; then
if [ "$1" = "min" ] || [ "$1" = "max" ] || [ $1 = "sum" ]; then
echo "ERROR: invalid command: $1"
exit 2
fi
fi
I've looked online and most of the answers seem to say its due to carriage returns being saved in the file. I created this using vi and set line breaks to unix. What is wrong?
Upvotes: 0
Views: 129