Skip to content

Option clustering

h908714124 edited this page Aug 27, 2021 · 16 revisions

Assume that mode flags (aka nullary options) -x and -z are defined, as well as a unary option -f. Then the following is valid input:

tar -xzf file.tgz

which is shorter than having to type out each option name in full:

tar -x -z -f file.tgz

The "attached" style of passing the argument of option -f also works:

tar -xzffile.tgz

but please note that for short (aka unix-style) options, = is not part of the syntax. For example, the following would pass the file name =file.tgz, which is probably not intended.

tar -xzf=file.tgz         # '=file.tgz'

Of course, when a gnu-style name like --file is used instead of -f, = is valid syntax to separate the value from the option name:

tar -xz --file=file.tgz   # 'file.tgz'
Clone this wiki locally