When displaying member names, tar takes care to avoid ambiguities caused by certain characters. This is called name quoting. The characters in question are:
Character | ASCII | Character name
|
---|---|---|
\a | 7 | Audible bell
|
\b | 8 | Backspace
|
\f | 12 | Form feed
|
\n | 10 | New line
|
\r | 13 | Carriage return
|
\t | 9 | Horizontal tabulation
|
\v | 11 | Vertical tabulation
|
The exact way tar uses to quote these characters depends on the quoting style. The default quoting style, called escape (see below), uses backslash notation to represent control characters, space and backslash. Using this quoting style, control characters are represented as listed in column ‘Character’ in the above table, a space is printed as ‘\ ’ and a backslash as ‘\\’.
GNU tar offers seven distinct quoting styles, which can be selected using --quoting-style option:
These styles are described in detail below. To illustrate their effect, we will use an imaginary tar archive arch.tar containing the following members:
# 1. Contains horizontal tabulation character. a tab # 2. Contains newline character a newline # 3. Contains a space a space # 4. Contains double quotes a"double"quote # 5. Contains single quotes a'single'quote # 6. Contains a backslash character: a\backslash
Here is how usual ls command would have listed them, if they had existed in the current working directory:
$ ls a\ttab a\nnewline a\ space a"double"quote a'single'quote a\\backslash
Quoting styles:
$ tar tf arch.tar --quoting-style=literal ./ ./a space ./a'single'quote ./a"double"quote ./a\backslash ./a tab ./a newline
$ tar tf arch.tar --quoting-style=shell ./ './a space' './a'\''single'\''quote' './a"double"quote' './a\backslash' './a tab' './a newline'
$ tar tf arch.tar --quoting-style=shell-always './' './a space' './a'\''single'\''quote' './a"double"quote' './a\backslash' './a tab' './a newline'
$ tar tf arch.tar --quoting-style=c "./" "./a space" "./a'single'quote" "./a\"double\"quote" "./a\\backslash" "./a\ttab" "./a\nnewline"
$ tar tf arch.tar --quoting-style=escape ./ ./a space ./a'single'quote ./a"double"quote ./a\\backslash ./a\ttab ./a\nnewline
For example:
$ tar tf arch.tar --quoting-style=locale `./' `./a space' `./a\'single\'quote' `./a"double"quote' `./a\\backslash' `./a\ttab' `./a\nnewline'
$ tar tf arch.tar --quoting-style=clocale "./" "./a space" "./a'single'quote" "./a\"double\"quote" "./a\\backslash" "./a\ttab" "./a\nnewline"
You can specify which characters should be quoted in addition to those implied by the current quoting style:
For example, using ‘escape’ quoting (compare with the usual escape listing above):
$ tar tf arch.tar --quoting-style=escape --quote-chars=' "' ./ ./a\ space ./a'single'quote ./a\"double\"quote ./a\\backslash ./a\ttab ./a\nnewline
To disable quoting of such additional characters, use the following option:
This option is particularly useful if you have added --quote-chars to your TAR_OPTIONS (see TAR_OPTIONS) and wish to disable it for the current invocation.
Note, that --no-quote-chars does not disable those characters that are quoted by default in the selected quoting style.