文档中的方括号是什么意思?

时间:2021-06-04 16:13:31

标签: bash syntax

我如何解释方括号?例如:

'case' 命令的语法是:

case WORD in
          [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]...
esac

我了解如何进行循环,但是在向 bash 文档寻求帮助时,我不知道如何解释括号。我的意思是这到底是什么意思,[(]

1 个答案:

答案 0 :(得分:1)

bash 复合命令的语法是使用手册页概要约定定义的。这些在 man(1) 中定义:

The following conventions apply to the SYNOPSIS section and can be used 
as a guide in other sections.

       bold text          type exactly as shown.
       italic text        replace with appropriate argument.
       [-abc]             any or all arguments within [ ] are optional.
       -a|-b              options delimited by | cannot be used
                          together.
       argument ...       argument is repeatable.
       [expression] ...   entire expression within [ ] is repeatable.