That's right, the directory list isn't being generated by ls, but by shell globbing. ls is only reading the list to give you detailed info.
http://mywiki.wooledge.org/glob For a simple list, you can even do this: Code:
echo */ |
Quote:
It appears that the ls command is in the second category. |
It seems everyone is doing it the hard way. The simplest way to list a directory and only the folders, without the full path is:
ls -F <whatever path you want> | grep / For example ls -F ./ | grep / will list the local directories ls -F Documents/ | grep / will list all of the directories in the folder Documents Hope this helps! |
the simplest way is:
Code:
ls -d */ |
To also show hidden directories, I prefer:
Code:
ls -al | grep ^d |
If you're not stuck on using ls, the command find . -maxdepth 3 -type d would list all directories under ./, for no more than three levels. Here's an example:
Code:
$ cd Scripts/ Or you could use this: Code:
$ tree -dL 2 |
command to list directories only
Hi,
Please try below command. it should be listed the directories only. ls -l|grep "^d" |
ls -dl `find /location/of/your/dir -type d`
Thanks to Marius Ducea http://www.ducea.com/2009/06/05/linu...nd-full-paths/ |
Quote:
($(..) is highly recommended over `..`, BTW.) Code:
$ mkdir 'aa bb' Code:
$ find . -type d -exec ls -dl '{}' \+ Code:
$ find . -type d -ls |
for ZSH ;)
alias lsd="ls -d \.#*(/)"
with setopt extendedglob |
Just the DIRs please.
Code:
ls -lF |
'Nother necro...
|
All times are GMT -5. The time now is 05:51 AM. |