Home > Mobile >  syntax error near unexpected token `done' | ./ABC.sh: line 14: `done'
syntax error near unexpected token `done' | ./ABC.sh: line 14: `done'

Time:12-16

I have no idea why I am getting a syntax error on line 14. Does anyone know why?

Exact error:

./ABC.sh: line 14: syntax error near unexpected token `done'

./ABC.sh: line 14: `done'

#!/bin/bash
echo "Please enter 1 character that is either 1, 2, or 3:"
read CHAR
while [ ! -z "$CHAR" ] do
 case $CHAR in [A,a,1])
  echo "This is A";;
  [B,b,2])
  echo "This is B";;
  [C,c,3])
  echo "This is C";;
  [D-z])
  echo "Sorry, the character you entered is not recognized, please try again";
 esac
done
echo "You have entered an empty string, process terminated"

It's due tomorrow, so I would really appreciate some help. Thank you so much!

CodePudding user response:

your last CASE condition isn't terminated properly:

  [D-z])
  echo "Sorry, the character you entered is not recognized, please try again";

should end with ;;


ah , and you're also missing the ; in :

while [ ! -z "$CHAR" ] ; do
  • Related