Debian - ls wraps filename with spaces in single quotes

By xngo on July 23, 2019

After upgrading to Debian 10 Buster, suddenly, ls wraps filename with spaces in single quotes. For example,

$ ls -al
-rwxrwxrwx 1 root root    0 Jul 23 17:45 'file with spaces.txt'
-rwxrwxrwx 1 root root    0 Jul 23 17:45 "I.can't.do.txt"

The coreutils developers thought it would be a good idea to make this the default behavior. For more details, see here.

Solution

To revert back to the old way, you can set the option on your ls command like these.

# Long form: https://www.gnu.org/software/coreutils/manual/html_node/Formatting-the-file-names.html
ls --quoting-style=literal
 
# Or, short form
ls -N

Or, you can put the following line in your ~/.bashrc file.

export QUOTING_STYLE=literal

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.