Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My bash script is 29 line but there is an error in line 30

i’m new in bash, so i was practicing bash and there is an error in line 30. but my script is 29 line.

The error is "./goz.sh: line 30: syntax error: unexpected end of file"
what is my fault?

here is my script:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#!/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
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

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading