Unix Command Documentaion Syntax
Command-line syntax for Unix and Unix-like systems.
Unix Command Documentation Syntax
Notation
[]
- Optional: Can be omitted
1 | ls [OPTIONS] [FILE...] # All valid: ls, ls -l, ls /home |
<>
- Required: Must provide actual values
1 | docker exec <CONTAINER> <COMMAND> # Must specify: docker exec myapp bash |
...
- Multiple: Can specify multiple values
1 | cp <SOURCE>... <DEST> # Copy multiple: cp file1.txt file2.txt /backup/ |
|
- Alternatives: Choose one (mutually exclusive)
1 | git log [--oneline | --graph] # Use only one |
Options vs Arguments
Short options: Single character with -
(can combine: -lah
)
Long options: Full words with --
(GNU extension: --verbose
)
Arguments: Required data (filenames, values)
Option-arguments: Values that options need
1 | tar -f archive.tar file.txt |
Option-arguments can be space-separated (-f file
) or attached (-ffile
). Long options use --output=file
or --output file
.
Common Patterns
1 | command [SHORT_OPTIONS] [--long-options] <REQUIRED> [OPTIONAL...] |
Standard options: -h/--help
, -v/--version
, -V/--verbose
End options marker: --
(everything after treated as arguments)
The syntax follows POSIX standards with GNU extensions for long options. Double dashes prevent ambiguity since -recursive
would be interpreted as -r -e -c -u -r -s -i -v -e
.
References: POSIX Utility Conventions, GNU Standards, getopt_long(3)