I am writing the following code:
if [ $opt -ge $max -o $opt -le 0 ]
then
echo "Bad";
else
echo "Good";
if [ $opt = "\" -o $opt = "/" ]
then
echo "Good";
else
echo "Invlaid"; //Line number 21
fi
fi //Line number 23 no Line number 24.
this shows an error:
./file.sh: line 21: unexpected EOF while looking for matching `"'
./file.sh: line 24: syntax error: unexpected end of file
If I place this code:
if [ $opt -ge $max -o $opt -le 0 ]
then
echo "Bad";
else
echo "Good";
fi //Line number 23 no Line number 24.
Then there is no error. I am not able to figure out the problem.
if [ $opt = "\" -o $opt = "/" ].-ofor logical OR is deprecated; you should use[ "$opt" -ge "$max" ] || [ "$opt" -le 0 ]instead--and quote your expansions!