Most unixoid commands feature short and long alternatives for command line options, like ls -a and ls --all, or ls -A and ls --almost-all. Why do those two ways exist? One is shorter to type, the other is easier to read and understand. But every time I write a shell script, I need to decide which I want to use. Is it known why the two alternatives exist? Which one was first, why was the other introduced. On DOS/Windows for example there's almost only case-insensitive one-letter options.


Originally there were only single-character options. Some programs took multiple-character options, but still with a single dash. AFAIK double-dash multiple-character options come from GNU; they were introduced because they are more readable and often more memorable (and you can have more than 52 of them). Many programs now have both: short options for when you're typing on the command line and remember the character, long options for scripts or on the command line if you only remember the longer option name.

  • 15
    +1 for mentioning that long options are better for scripts, because they help document things – Norman Gray Aug 11 '10 at 8:59
  • 5
    As for "only 52 of them": Try ls -BartSimpsonIsJustCool (or Great if you're on Solaris. – Aaron Digulla Aug 11 '10 at 9:31
  • 1
    @AaronDigulla Is this Easter egg? – user712092 Oct 25 '12 at 16:50
  • 5
    @user712092 No, it's a trick. Under Linux, everything after the I is the argument to the -I option, so it only makes a difference if you have a file called sJustCool in the current directory. The -BartSimpson part can be reordered, except that the S (sort by size) has to stay after the t (sort by date). Also m has no effect when n or o are present. So the command is equivalent to ls -BSainopsr, and if I haven't missed anything you can't remove another letter to achieve the same output and you can reorder these letters freely. – Gilles Oct 25 '12 at 18:51
  • 2
    @Gilles: by the way, to be as accurate as possible, there may be 62 different short options (including digits), not 52. Consider gzip -9 filename for instance. – Radko Dinev Aug 23 '14 at 13:41

You might guess that it is a matter of taste. When typing on the command line a short option might be preferred, especially in the case of run-together-options (e.g. ls -AL). The long options are better at conveying intent, thus you don't need to consult the man page when you read ls --almost-all --dereference.

Naturally, as you gain experience, you might learn that both of the -A and -L short options are sufficiently well known, and don't require this extra documentation. Especially in a complex command that may combine several commands in interesting ways with evaluation, redirection, etc. In such a case you might prefer brevity over documentation.


Another purpose I can see in having different ways of specifying parameters (short and long) is that when typing, Unix/Linux command-line folks like to have as short as possible commands. However, those can become cryptic, and if a script is written using those short versions, they can become hard to understand down the road. Using the long version can make the SAME command more readable and understandable by someone who is not the guru of this command, especially if this command is actually a locally written script as opposed to a well-known command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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