Command line: When to use “-” (single hyphen) or “–” (double hyphen)

This post is also available in: Deutsch (German)

On the command line, the - character is used to indicate a short form argument, which is a single-letter argument that can be specified using a single hyphen and the letter of the argument. For example, the -h argument is commonly used to show the help message for a command, and the -v argument is commonly used to enable verbose output. You can only use the single hyphen (-) when the argument consists of a single letter.

Examples where single hyphen can be used: -h-Rand-f, but you can not use single hyphens for multi-letter arguments such as -verbose or -help.

The -- characters are used to indicate a long form argument, which is a multi-letter argument that can be specified using a double hyphen and the name of the argument. For example, the --help argument is commonly used to show the help message for a command, and the --verbose argument is commonly used to enable verbose output.

Examples where double hyphens can be used: --verbose--server and --help, but you can’t use them for single-letter arguments like --h or --R 

Examples of how to use single or double hyphens:

# Show the help message for a command using the -h short form argument
my_command -h

# Enable verbose output for a command using the --verbose long form argument
my_command --verbose

# Combine multiple arguments
my_command --verbose --server https://techoverflow.net -f 0.1