Question

In the man pages I came across various syntaxes to write Linux/Unix commands, which include square brackets, angular brackets, hyphens (-) and double hyphens (--) in various combinations. What is the meaning of these syntax conventions?

[ ]
< >
[< >]
[--]
-
--
[< >...]
Was it helpful?

Solution

Square Brackets [ ]

The square brackets ( [ ] ) indicate that the enclosed element (parameter, value, or information) is optional. You can choose zero or more items. Do not type the square brackets themselves in the command line.

Example: [global options], [source arguments], [destination arguments]

Angle Brackets < >

The angle brackets ( < > ) indicate that the enclosed element (parameter, value, or information) is mandatory. You are required to replace the text within the angle brackets with the appropriate information. Do not type the angle brackets themselves in the command line.

Example: -f [set the File Name variable], -printer <printer name>, -repeat <months> <days> <hours> <minutes>, date access <mm/dd/yyyy>

In Unix-like systems, the ASCII hyphen–minus is commonly used to specify options. The character is usually followed by one or more letters. An argument that is a single hyphen–minus by itself without any letters usually specifies that a program should handle data coming from the standard input or send data to the standard output. Two hyphen–minus characters ( -- ) are used on some programs to specify "long options" where more descriptive option names are used. This is a common feature of GNU software.

Just do 'ls --help' and look at the options, it should be obvious to you.

 -A, --almost-all           do not list implied . and ..
     --author               with -l, print the author of each file
 -b, --escape               print octal escapes for nongraphic characters
     --block-size=SIZE      use SIZE-byte blocks
 -B, --ignore-backups       do not list implied entries ending with ~
 -c                         with -lt: sort by, and show, ctime (time of last
                              modification of file status information)
                              with -l: show ctime and sort by name
                              otherwise: sort by ctime'
 -C                         list entries by columns
     --color[=WHEN] 

OTHER TIPS

There are also the uncommon {} brackets used which from my search is for a required options that can be specified in mutually exclusive ways, for example, {-A|--almost-all}.

"{}" are used in conjunction with a vertical bar to indicate cases where exactly one of the specified options may be used

Convention used by UNIX man pages

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top