Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I did some searching, but I cannot find documentation on how Unix usage works. I know something (mostly through trial and error) but, for example, how do I know that

/usr/bin/ls  [-aAbcCdeEfFghHilLmnopqrRstuvVx1@] [file]...

means that you can include more than one option? That is,

ls -la

Where is some documentation on what the usage syntax is?

share|improve this question

migrated from stackoverflow.com Apr 23 '10 at 22:27

This question came from our site for professional and enthusiast programmers.

    
POSIX does have some say on how usage/help displays should be formatted, but beyond the core utilities (GNU), few follow it consistently. –  Tim Post Apr 23 '10 at 17:17
    
@Tim, I don't have anything on usage there. –  sixtyfootersdude Apr 23 '10 at 18:58

3 Answers 3

up vote 22 down vote accepted

It's true there is no RFC or anything, but you don't go too far off base if you stick to these guidelines:

  1. Anything in angle brackets < > means the option is required:
    <foo>

  2. Anything in square brackets [ ] means the option is optional:
    [bar]

  3. Options separated by a pipe | means those are the valid values:
    --baz=one|two|three

  4. Single-letter options start with one dash:
    -a

  5. Multi-letter options start with two dashes:
    --foo-bar

  6. (based on #4) A single dash with multiple letters usually means the union of those individual single-letter options rather than a multi-letter option. Not all commands support that kind of union. Example:
    -aAbBcC is the same as -a -A -b -B -c -C

share|improve this answer
1  
+1 - Teach a man to fish ... –  Tim Post Apr 23 '10 at 17:14
1  
man man or man 5 man –  mpez0 Nov 13 '10 at 14:35

The usage lines don't follow anything consistent.

You should use man ls or info ls to get a more consistent level of information.

share|improve this answer

There is no strict structure for man pages, but the following covers most commands.

From MANUAL PAGES(5), BSD File Formats Manual, section "MANUAL PAGE SYNTAX":

In manual page syntax, anything in a normal text font is required text. Anything in a boldface font is a flag or a subcommand. Anything underlined is a user-specified argument such as a filename.

Any argument surrounded by brackets is considered to be optional. For example, [ filename ] would indicate an optional filename argument.

Flags, arguments, or subcommands separated by a vertical separator (|) are mutually exclusive. For example, if -a turns on an option and -b turns off the option, the syntax for this command might be -a | -b.

In some cases, you may even see entire groups of arguments wrapped with brackets and separated by a vertical separator. This is one way of showing that a command has more than one valid syntax. In other manual pages, this is expressed by having multiple lines in the synopsis, each of which begins with the command name. The separated format is more common (and more readable), but is not always possible for commands with particularly complex syntax.

Finally, the most important notational convention is the use of the ellipsis (...). This indicates that additional arguments may be added at this point.

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.