1

I need to write a little bash program. Now i want to use the case function but i receive the error message

./arbeit1.sh: line 26: syntax error near unexpected token ;;' ./arbeit1.sh: line 26: auswertung();;'

read auswahl 
case "$auswahl" in
"1")
    echo "Sternbox";;
"2")
    auswertung();;
"3")
    array();;
"4")
    exit;;
*)
    echo "Falsche Eingabe - Probieren Sie es nochmal";;
esac
2
  • 4
    Don't use "()" to call a function. It is used to define a new function, and the body should follow, hence the syntax error. Commented Jul 31, 2017 at 8:59
  • In bash, functions are called in exactly the same way as any other command: it is not C/C++/Java/C# ! Commented Jul 31, 2017 at 9:02

1 Answer 1

1

Problem are the parenthesis in your function calls. That is not valid BASH code.

Try the following:

read auswahl
case $auswahl in
  "1")
    echo "Sternbox"
    ;;
  "2")
    auswertung     # note no () here!
    ;;
  "3")
    array
    ;;
  "4")
    exit 0
    ;;
  *)
    echo "Falsche Eingabe - Probieren Sie es nochmal"
esac
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.