Ubuntu – What do the square brackets mean in an ubuntu terminal command’s synopsis

command line

For the 'find' command, the synopsis from

man find

is:

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

What do the square brackets mean? I used to think they just meant an argument or flag was optional, but [path…] and [expression] can't both be optional for find, right…?

Best Answer

What do the square brackets mean?

Square brackets in a command synopsis mean optionality (i.e. whatever is listed inside of them is optional / not required in order to run the command).

I used to think they just meant an argument or flag was optional, but [path...] and [expression] can't both be optional for find, right...?

They can; running find without [path...] and [expression] just prints the list of folders / files in the current working directory's hierarchy without any condition.


The [<expr>] construct along with other symbols / constructs commonly used in command synopses (e.g. |, alternation, and {<expr>}, repetition) are the same used to define formal languages in Extended Backus-Naur Form (EBNF), so EBNF's syntax is a a good reference to understand / remember what symbols / constructs in command synopses mean.