Issue
I'm new in bash, so I was practicing bash and there is an error in line 30. but my script is 29 lines.
The error is "./goz.sh: line 30: syntax error: unexpected end of file
"
what is my fault?
here is my script:
#!/bin/bash
echo -e "What is your eye color's origin? \n"
echo -e "To learn, please enter; \n"
echo -e "For green 1\nfor brown 2\nfor blue 3 \nfor read 4"
while true
read -p "pick a color please (for quit (q)):\n" goz
case $goz in
1)
echo "Mediterranean"
;;
2)
echo "Asian"
;;
3)
echo "Scandinavian"
;;
4)
echo "Dark Lord of the sith"
;;
q | Q)
echo "quitting"
break
;;
*)
echo "You are never been existed."
;;
esac
Solution
The syntax for while
is
while [CONDITION]
do
[COMMANDS]
done
so modifying the above code by adding do
and done
like below should fix the error.
#!/bin/bash
echo -e "Göz renginiz nereden geliyor? \n"
echo -e "Öğrenemek için lütfen: \n"
echo -e "Yeşil için 1'e\nkahverengi için 2'ye\nMavi için 3'e \nkırmızı için 4'e basınız."
while true
do
read -p "lütfen bir renk seçiniz (çıkmak için 'q' ya basnız):\n" goz
case $goz in
1)
echo "akdeniz kökenli"
;;
2)
echo "asya kökenli"
;;
3)
echo "iskandinav kökenli"
;;
4)
echo "dark lord of the sith"
;;
q | Q)
echo "çıkılıyor"
break
;;
*)
echo "Sen aslında yoğsun yoğ. hiç var olmadın, yoğsun."
;;
esac
done
Answered By - Arun Murugan Answer Checked By - Candace Johnson (WPSolving Volunteer)