Linux bash中的case:;第4行:意外标记`)和#x27附近的语法错误&引用;

Linux bash中的case:;第4行:意外标记`)和#x27附近的语法错误&引用;,linux,bash,syntax-error,case,Linux,Bash,Syntax Error,Case,bash中的案例: 第4行:意外标记“)”附近的语法错误 我试图在Bash中使用命令case(再次在我的Raspberry Pi上),但当我运行脚本时,Bash会抛出错误。我读过很多教程,我想我做的和他们一样,但有些地方不太对劲 这是我的密码: #!/bin/bash case "$1" in help) echo "You asked for help. Sorry, I'm busy." *) echo "You didn't say anything. Tr

bash中的案例:

第4行:意外标记“)”附近的语法错误

我试图在Bash中使用命令
case
(再次在我的Raspberry Pi上),但当我运行脚本时,Bash会抛出错误。我读过很多教程,我想我做的和他们一样,但有些地方不太对劲

这是我的密码:

#!/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
以下是输出(文件名为newmkdir,我运行时没有参数):

我试图让我的脚本解释
help
,然后在下一行输出任何其他内容


(请注意,这只是一个故障脚本的示例。此脚本没有任何意义,甚至可能没有意义,它只是一个测试。)

您缺少
在每个图案的末尾:

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

可以将其视为编程语言中的
break
语句。在
案例

中,它们是您需要的
;的必修课在每种情况下。您可能会发现有用。从技术上讲,
在esac之前是可选的,但这不是取消它的好理由。谢谢。。。在我发布这篇文章之后,我意识到了标签的“问题”,但无论如何,感谢你纠正它。
#!/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