What are the differences between "-" and "--" in commands?

Peng Zhang

I often see a single dash - or double dash -- followed by linux commands or other installed linux programs.

What are the differences between single dash and double dashes?

Is it just about abbreviation? For example, -v means --verbose most of the time.

muru

It is a matter of convention. POSIX standard programs usually only have single character options, and they're all prefixed with a single hyphen. The longer versions are a GNU improvement for clarity, as far as I can tell, and usually are prefixed with double hyphens. You can see this in the libraries and programs used to parse options - getopt and gnu-getopt respectively. Non-GNU and non-POSIX-compliant programs may do something else altogether. Note that you really can't be sure that the long form of an argument may be the same from program to program. -f usually means --force, but not with apt-get install (common misconception). -v may mean version - usually, or --verbose, and so on. Check the man pages or other documentation to be sure. Also have a look at the Wikipedia article on getopt. All this predates Linux by a decade or more.

dd is an example of a POSIX standard utility which doesn't have any hyphenated options at all. find is the classic example of a POSIX standard utility that has word options with single hyphens - nearly all of find's options are multiple characters long. ps supports multiple option styles:

This version of ps accepts several kinds of options:

1   UNIX options, which may be grouped and must be preceded by a dash.
2   BSD options, which may be grouped and must not be used with a dash.
3   GNU long options, which are preceded by two dashes.

GNU tar also supports multiple option styles.

As a matter of usage, prefer the long options in scripts if you can be sure that the scripts will be run in compatible environments - the improvement in clarity is a blessing when debugging. For portability, the short options are preferred.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

What are the differences between feather and parquet?

From Java

What are differences between SystemJS and Webpack?

From Java

What are the differences between .gitignore and .gitkeep?

From Java

What are the differences between type() and isinstance()?

From Java

What are the differences between Bazel and Gradle?

From Java

What are the differences between Conda and Anaconda?

From Java

What are the differences between QEMU and VirtualBox?

From Dev

What are the differences between lenses and zippers?

From Dev

What are the differences between Shared and Static?

From Dev

What are the differences between activity and fragment?

From Dev

What is the differences between .as and .fla

From Dev

What are the differences between XDefaultScreen and XDefaultScreenOfDisplay?

From Dev

What are the differences between Abstraction and Decomposition?

From Dev

what are the differences between setInterval and requestanimationframe?

From Dev

What are the differences between karma reporters?

From Dev

what are the differences between $document and $window?

From Dev

What are the differences between TLS and PGAS?

From Dev

What are the differences between a stream and a sample?

From Dev

What are differences between SQL queries?

From Dev

l, ls & la -- what are the differences, and are there more of these commands?

From Dev

What are the performance differences between MongoDB collection methods and database commands

From Dev

What is the differences between 'ready' and 'on'?

From Dev

What are the differences between this and this() in java

From Dev

Execution time differences between time commands

From Dev

What differences between `type cd` and `which cd` commands in linux?

From Dev

Differences between dir and ls FTP Commands

From Dev

Vim netrw - differences between Explore commands?

From Dev

What are the differences between > and space?

From Dev

What are the differences between `key` and `type` commands of xdotool?

Related Related

  1. 1

    What are the differences between feather and parquet?

  2. 2

    What are differences between SystemJS and Webpack?

  3. 3

    What are the differences between .gitignore and .gitkeep?

  4. 4

    What are the differences between type() and isinstance()?

  5. 5

    What are the differences between Bazel and Gradle?

  6. 6

    What are the differences between Conda and Anaconda?

  7. 7

    What are the differences between QEMU and VirtualBox?

  8. 8

    What are the differences between lenses and zippers?

  9. 9

    What are the differences between Shared and Static?

  10. 10

    What are the differences between activity and fragment?

  11. 11

    What is the differences between .as and .fla

  12. 12

    What are the differences between XDefaultScreen and XDefaultScreenOfDisplay?

  13. 13

    What are the differences between Abstraction and Decomposition?

  14. 14

    what are the differences between setInterval and requestanimationframe?

  15. 15

    What are the differences between karma reporters?

  16. 16

    what are the differences between $document and $window?

  17. 17

    What are the differences between TLS and PGAS?

  18. 18

    What are the differences between a stream and a sample?

  19. 19

    What are differences between SQL queries?

  20. 20

    l, ls & la -- what are the differences, and are there more of these commands?

  21. 21

    What are the performance differences between MongoDB collection methods and database commands

  22. 22

    What is the differences between 'ready' and 'on'?

  23. 23

    What are the differences between this and this() in java

  24. 24

    Execution time differences between time commands

  25. 25

    What differences between `type cd` and `which cd` commands in linux?

  26. 26

    Differences between dir and ls FTP Commands

  27. 27

    Vim netrw - differences between Explore commands?

  28. 28

    What are the differences between > and space?

  29. 29

    What are the differences between `key` and `type` commands of xdotool?

HotTag

Archive