case in bash: “line 4: syntax error near unexpected token `)'”

前端 未结 1 959
耶瑟儿~
耶瑟儿~ 2021-01-13 09:51

case in bash:

line 4: syntax error near unexpected token `)\'

I\'m trying to use the command case in Bash (on my R

相关标签:
1条回答
  • 2021-01-13 09:54

    You are missing ;; at the end of each pattern:

    #!/bin/bash
    case "$1" in
            help)
                echo "You asked for help. Sorry, I'm busy."
                ;;
            *)
                echo "You didn't say anything. Try 'help' as the first argument."
                ;;
    esac
    

    Think of it as a break statement in a programming language. They are compulsory on case.

    0 讨论(0)
提交回复
热议问题