-1

How do I interpret square brackets? For example:

The syntax of the 'case' command is:

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

I understand how to do the loop but when asking for help from bash documentation I did not know how to interpret the brackets. I mean what the hell does it mean, [(]?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
dababy
  • 13
  • 1
  • The bash manual uses that to indicate optional parts. You can write the (useless) command `case $word in esac` with no patterns. – glenn jackman Jun 04 '21 at 16:20
  • @glennjackman sorry man but thank you I'm learning english and i find it difficult to read the manual – dababy Jun 04 '21 at 16:29
  • Duplicate on Unix & Linux: [What do square brackets in bash case statement mean?](https://unix.stackexchange.com/q/164690/117037) – wjandrea Jun 04 '21 at 16:36

1 Answers1

1

The syntax of bash compound commands is defined using the man page synopsis conventions. These are defined in 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.
Brian61354270
  • 8,690
  • 4
  • 21
  • 43