Command-Line Options

Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting
Prev |  | Next

# Appendix G. Command-Line Options

Many executables, whether binaries or script files, accept options to modify their run-time behavior. For example: from the command-line, typing command -o would invoke command, with option `o`.

# G.1. Standard Command-Line Options

Over time, there has evolved a loose standard for the meanings of command-line option flags. The GNU utilities conform more closely to this "standard" than older UNIX utilities.

Traditionally, UNIX command-line options consist of a dash, followed by one or more lowercase letters. The GNU utilities added a double-dash, followed by a complete word or compound word.

The two most widely-accepted options are:

- `-h`

  `--help`

  Help: Give usage message and exit.

- `-v`

  `--version`

  Version: Show program version and exit.

Other common options are:

- `-a`

  `--all`

  All: show all information or operate on all arguments.

- `-l`

  `--list`

  List: list files or arguments without taking other action.

- `-o`

  Output filename

- `-q`

  `--quiet`

  Quiet: suppress `stdout`.

- `-r`

  `-R`

  `--recursive`

  Recursive: Operate recursively (down directory tree).

- `-v`

  `--verbose`

  Verbose: output additional information to `stdout` or `stderr`.

- `-z`

  `--compress`

  Compress: apply compression (usually gzip).

However:

- In tar and gawk:

  `-f`

  `--file`

  File: filename follows.

- In cp, mv, rm:

  `-f`

  `--force`

  Force: force overwrite of target file(s).

| Many UNIX and Linux utilities deviate from this "standard," so it is dangerous to assume that a given option will behave in a standard way. Always check the man page for the command in question when in doubt.

A complete table of recommended options for the GNU utilities is available at the GNU standards page.

Prev | Home | Next
A Detailed Introduction to I/O and I/O Redirection |  | Bash Command-Line Options