Just out of curiosity, I was wondering if there is a reason for the extra space when I type ls
in the Desktop directory. Compare...
~/Desktop$ ls
file1 file2 file3
...to...
~/Documents$ ls
file1 file2 file3
Notice that when I type ls
on the Desktop I get an extra space at the beginning of the line (not part of the filename). I can't find any other example location where I get this extra space at the beginning of the line. Does anyone else get this? Is there a reason?
NB: I am using Ubuntu Bionic Beaver LTS release and the default terminal that ships with it.
The extra space appears when you have file names in your directory needing
'
around them (e.g. file names with spaces or other special characters).After removing the 'strange' files I get:
I'm pretty sure
file1 file2 file3
is not what's exactly shown on your screen. You omitted precious information (the actual filenames) that might easily be relevant.My assumption is that you have a filename that contains a space or other special character.
Newer version of coreutils's
ls
quote such filenames, typically in single quotes. Plus, if there's at least one file requiring such quoting, it adds a space in front of all other filenames so that they align up "nicely" if they happen to be underneath each other, that is, the single quote mark (apostrophe) is ignored for alignment.See
--quoting-style
and-N
in the manual page ofls
for some more details, and the section "Formatting the file names" in its info page for even more details. You might e.g. consider aliasingls
tols -N
.