$ touch "z\1"
$ ls -Q
"z\\1"
Why "ls -Q" give output as "z\\1"
if the file name is 'z\1
'?
The output is coming with double slash in between 'z' and '1'.
The -Q
-Switch (also --quote-names
) will quote the names. How this quoting is done is defined by the --quoting-style
-Switch.
Snippet from the man page:
--quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape
This will lead to the following result:
ls --quoting-style=literal "z\1"
=> z\1
ls --quoting-style=locale "z\1"
=> ‘z\\1’
ls --quoting-style=shell "z\1"
=> 'z\1'
ls --quoting-style=shell-always "z\1"
=> 'z\1'
ls --quoting-style=c "z\1"
=> "z\\1"
ls --quoting-style=escape "z\1"
=> z\\1
I can't tell you what the default is. But it have to be one of these locale, c, escape