$ touch "z1" $ ls -Q "z\1"
Why “ls -Q” give output as "z\1" if the file name is ‘z1‘?
The output is coming with double slash in between ‘z’ and ‘1’.
Advertisement
Answer
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 "z1"=>z1ls --quoting-style=locale "z1"=>‘z\1’ls --quoting-style=shell "z1"=>'z1'ls --quoting-style=shell-always "z1"=>'z1'ls --quoting-style=c "z1"=>"z\1"ls --quoting-style=escape "z1"=>z\1
I can’t tell you what the default is. But it have to be one of these locale, c, escape