Useful example of ls -b, --escape
All of your characters are graphic (they have visible glyphs). Try a filename containing whitespace and invisible characters:
$ touch $'\n\t\b\a\b'
$ ls -b
\n\t\b\a\b
$ echo *
$ printf "%q\n" *
$'\n'$'\t'$'\b'$'\a'$'\b'
An actual useful example where the output would be tricky otherwise: filenames that accidentally had the \r
character inserted in them because DOS file endings got in the way somewhere in the middle of an operation:
$ od -c file-list
0000000 s o m e - f i l e . t x t \r \n
0000017
$ xargs -a file-list touch
$ ls -b
\n\t\b\a\b file-list some-file.txt\r
I have actually seen this in some post on U&L. Personally, I'd usually use ls -q
for copy-pasting to the command-line itself:
$ ls -q
''$'\n\t\b\a\b' ' ' file-list 'some-file.txt'$'\r'
The default behaviour in newer versions of ls
is ls -q
for interactive usage: Why is 'ls' suddenly wrapping items with spaces in single quotes?
Example I found myself
$ touch "Hello This is my file"
$ ls
Hello This is my file
With -b
option
$ ls -b
Hello\ This\ is\ my\ file
Isn't the 2nd one better when I want to use the output somewhere else in my code?
The way you created the files was probably by directly pasting the test. To create files with backslash escapes you need to use $'...'
type of quoting.
Thus creating files should be:
$ touch one$'\n'two three$'\t'four
And the ls -b
will show us their representation:
$ ls -b
one\ntwo three\tfour
While default ls
will not:
$ ls
one?two three?four
Note, that having backslash escapes in files can break your scripts, hence one should never parse ls. And exactly the main purpose for ls -b
- to see what filenames have and potentially troubleshoot them.
In addition to muru's answer which explains that none of the characters in your filename are non-graphic, I will point out that your filename does not actually contain any backslashes (the shell removes them when running the command of course)
If it did, -b
would cause them to be printed with escapes:
$ touch 'hi\(zanna' hi\(zanna
$ ls
hi(zanna hi\(zanna
$ ls -b
hi(zanna hi\\(zanna