7 Command-line argument conventions Flashcards
Command options are by convention single letters prefixed by a hyphen (“-h”). Unless followed by option parameters, single character flag options can often be concatenated:
$ ls -l -a -t
$ ls -lat
GNU tools offer alternatively long option names prefixed by two hyphens (“–help”). Arguments not starting with hyphens are typically filenames, hostnames, URLs, etc.
$ gcc –version
$ curl –head http://www.cl.cam.ac.uk/
–
The special option “–” signals in many tools that subsequent words are arguments, not options. This provides one way to access filenames starting with a hyphen:
$ rm – -i
$ rm ./-i
”-“
The special filename “-” signals often that standard input/output should be used instead of a file.
Who implements these special conventions for – and -
All these are conventions that most – but not all – tools implement (usually via the getopt library function), so check the respective manual first.
The shell remains ignorant of these “-” conventions!