7 Command-line argument conventions Flashcards

1
Q

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:

A

$ ls -l -a -t

$ ls -lat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

GNU tools offer alternatively long option names prefixed by two hyphens (“–help”). Arguments not starting with hyphens are typically filenames, hostnames, URLs, etc.

A

$ gcc –version

$ curl –head http://www.cl.cam.ac.uk/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

”-“

A

The special filename “-” signals often that standard input/output should be used instead of a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Who implements these special conventions for – and -

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly