Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have not being able to understand the synopsis in manpage of a command. For example, let's see the manpage of man itself. By man man:

SYNOPSIS
       man  [-C  file]  [-d]  [-D]  [--warnings[=warnings]]  [-R encoding] [-L
       locale] [-m system[,...]] [-M path] [-S list]  [-e  extension]  [-i|-I]
       [--regex|--wildcard]   [--names-only]  [-a]  [-u]  [--no-subpages]  [-P
       pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justifi‐
       cation]  [-p  string]  [-t]  [-T[device]]  [-H[browser]] [-X[dpi]] [-Z]
       [[section] page ...] ...
       man -k [apropos options] regexp ...
       man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
       man -f [whatis options] page ...
       man -l [-C file] [-d] [-D] [--warnings[=warnings]]  [-R  encoding]  [-L
       locale]  [-P  pager]  [-r  prompt]  [-7] [-E encoding] [-p string] [-t]
       [-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ...
       man -w|-W [-C file] [-d] [-D] page ...
       man -c [-C file] [-d] [-D] page ...
       man [-hV]
  1. Is synopsis mean the prototype of usage of the command?
  2. what do those [...]and [...] inside [...] mean? Do they mean something optional?
  3. Does | mean OR?
  4. What does , mean in [-m system[,...]]?
  5. Are the rules for writing and reading synopsis similar to Regex? But I feel they are not quite the same.
share|improve this question

2 Answers 2

up vote 7 down vote accepted
  1. The synopsis section usually gives some example use-cases. Sometimes sub-commands have different options, so several examples might be shown.
  2. Brackets [] always denote optional switches, arguments, options, etc.
  3. Yes, the pipe | means or, particularly when inside brackets or parenthesis.
  4. Brackets in brackets just means that if the the second part is dependent on the first, but also itself optional. Some switches you can use on their own or add a value to them. Commas at the start of a bracket would indicate there can be multiple comma separated values.
  5. They lean on Regex concepts, but are meant to be human readable so don't follow all the escaping rules etc.
share|improve this answer
    
Thanks! Are there some references explaining the syntax of synopsis? –  Tim Aug 1 '11 at 20:24
    
@Tim: That's one of the craziest ones I've seen, I think if you read a few more you'll get the hang of it. It's just convention, not magic. –  Caleb Aug 1 '11 at 20:46

If you want a reference, they are loosely based on EBNF.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.