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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Where did the convention of using single dashes for letters and doubles dashes for words come from and why is continued to be used?

For example if I type in ls --help, you see:

  -a, --all                  do not ignore entries starting with .
  -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 ~

I tried googling - and -- convention even with quotes with little success.

share|improve this question
Just being nit-picky here, but the character - is technically called a hyphen. We use the word "dash" to refer to the em dash (—) in most cases, and sometimes the en dash (–), but neither of which is a hyphen (-). – chharvey Jun 20 '15 at 16:20
up vote 39 down vote accepted

In The Art of Unix Programming Eric Steven Raymond describes how this practice evolved:

In the original Unix tradition, command-line options are single letters preceded by a single hyphen... The original Unix style evolved on slow ASR-33 teletypes that made terseness a virtue; thus the single-letter options. Holding down the shift key required actual effort; thus the preference for lower case, and the use of “-” (rather than the perhaps more logical “+”) to enable options.

The GNU style uses option keywords (rather than keyword letters) preceded by two hyphens. It evolved years later when some of the rather elaborate GNU utilities began to run out of single-letter option keys (this constituted a patch for the symptom, not a cure for the underlying disease). It remains popular because GNU options are easier to read than the alphabet soup of older styles. 1

[1] http://www.faqs.org/docs/artu/ch10s05.html

share|improve this answer

There are probably a few reasons that the two methods are used. One, of course, is tradition. Programmers and users are humans, and humans expect things to work in a certain way. If there's no reason to change (and really, for a command line, there's not much reason to change), then don't.

That being said, I know that there are tools out there that use the single hyphen for a long option, or even get rid of the hyphens altogether. These tools can be difficult at first, and tend to stick out as warts in an otherwise-unified system.

When I was learning the difference between the two (and before it became second nature), I would always remember that the "short" hyphen matches the "short" options, while the "long" (or double) hyphen matches the "long" options. I don't know if that reasoning was used in the development of the double-hyphen style, but it's a possiblity.

share|improve this answer

One reason for continuing to use the single letter options is because they can be strung together: ls -ltr is a lot easier to type than ls --sort=time --reverse --format=long. There are a number of times when both are good to use. As for searching for this topic, try "unix command line options convention".

share|improve this answer
+1 for answering the question about searching. – rahmu Oct 1 '11 at 22:20
+1 Thanks this really does help with the logic behind the implementation. – Larry Oct 1 '11 at 23:29

In wikipedia Command-line interface it is reported:

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.

share|improve this answer
This doesn't answer the question of where the convention came from and why it continues to be used. – chharvey Jun 20 '15 at 16:38

Your Answer


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.