can someone explain why I can not get ls-l to show directory?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
can someone explain why I can not get ls-l to show directory?
I guess I am missing something that is right in front of me. I started out wanting to chmod a directory, but get message "no such directory".
Here is results I am getting from ls -l:
debian-desktop:/home/mike# ls -l /home/mike/mnt/music/music/FLAC
total 36
drwxrwxrwx 8 mike mike 4096 2008-06-27 12:10 christmas
drwxrwxrwx 30 mike mike 4096 2008-06-27 12:14 classical
drwxrwxrwx 21 mike mike 4096 2008-06-27 12:00 country
drwxrwxrwx 55 mike mike 4096 2008-10-26 10:48 EAC
drwxrwxrwx 12 mike mike 4096 2008-06-27 12:15 new age
drwx------ 11 mike mike 4096 2008-10-18 19:58 new music
drwxrwxrwx 163 mike mike 4096 2007-09-16 09:01 PowerAMP
drwxrwxrwx 5 mike mike 4096 2008-06-27 12:15 reggae
drwxrwxrwx 34 mike mike 4096 2008-06-27 12:09 Those girls
debian-desktop:/home/mike# ls -l /home/mike/mnt/music/music/FLAC/new music
ls: /home/mike/mnt/music/music/FLAC/new: No such file or directory
ls: music: No such file or directory
debian-desktop:/home/mike#
So from the first command I can see my directory named "new music". I try to run the same command to that directory, and you can see what I get.
The simple thing you are missing is that the shell is parsing the command and dividing the arguments into two arguments "new" and "music". To get what you want you have to escape the blank as in
ls new\ music
That is one reason you see very few directories with a space in the names, especially in directories of folks who primarily use the command line.
The shell interprets a number of character as *special* tokens. The blank space is one of those, and it's used to separate arguments. You are using ls incorrectly and it sees two arguments, and not one. The first one is "/home/mike/mnt/music/music/FLAC/new", and the second one is "music".
If you want bash to interpret both as a single argument, then you have to quote is, to avoid the interpretation of the blank space as an argument separator. That way, bash will know that the space is part of your string, and not a special character.
Code:
ls -l "/home/mike/mnt/music/music/FLAC/new music"
You can also escape the blank space. When a given character is escaped, bash ignores it's special meaning. This is the way that escaping works:
Code:
ls -l /home/mike/mnt/music/music/FLAC/new\ music
That backslash in front of the blank space will prevent bash from parsing it, produced the same effect that this of the quotation marks.
Last, but not least, you might be interested in the bash autocompletion feature: just write enough of the path so it's identifiable by bash, and then press TAB to autocomplete it.
Code:
ls -l /home/mike/mnt/music/music/FLAC/new<press tab here>
Quite a time saver. And you can use it at any point:
Code:
ls -l /ho[TAB]m[TAB]mnt[TAB]mus[TAB]mus[TAB]F[TAB]/new[TAB]
You might also be interested in knowing that the ~ is a much shorter way to refference your home directory, so you could have writen instead:
The simple thing you are missing is that the shell is parsing the command and dividing the arguments into two arguments "new" and "music". To get what you want you have to escape the blank as in
ls new\ music
That is one reason you see very few directories with a space in the names, especially in directories of folks who primarily use the command line.
Norm
The reason I dislike dir names with spaces is not because of having to write a backslash to reference them. Autocompletion makes that little problem almost irrelevant, because it will add the backslash when needed. And anyway writing a backslash is not a big problem.
But having file and dir names with spaces in the middle makes them harder to read for me. Overall in ls listings where there are many columns. It can be problematic. It's just the way my brain works. I am sure that it poses no problem for other people.
For concrete purposes I use names with spaces (for example, for films, which I store as Title-Director-Year.avi. Both the title and director's name usually contain spaces, but I only see this files listed in mc, and even if I use ls, the file name is that big that it there's no additional columns anyway.
PO'd at myself for not thinking of using tab. I remember seeing instructions to use tab when I was attempting to edit a kernal name. Forgot all about it.
Now I will search for instructions on changing permissions.
@i92guboj: ah, but remember auto-complete is not avail in a script.
I'm old-school Unix. I NEVER use spaces in filenames or dirs...
Well, that's out of context. But in any case, that would be the work of your text editor. I am sure that there are creative ways to autocomplete stuff in vim and emacs, which can do virtually anything.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.