How to just list directories using ls command
Hi
How do i use the ls command to just list the directories in a particular folder? Regards Shelton. |
To list just directories of a particular directory:
ls -l <dir> | grep ^d If you are inside the directory and just want to the list only directories then it's: ls -l | grep ^d At least that's what I use :). Other's my use different commands. -twantrd |
Hi,
or simpler: ls -d Oliv' |
No. ls -d is for displaying a directory "the same as" a file, that is not displaying it's content. Example: you want to see all hidden files (beginning with a .), but you don't want to list the whole content of . and ..
Code:
ls -ad .* Code:
find . -mindepth 1 -maxdepth 1 -type d -print |
Simpler:
Code:
ls -d */ |
wow that is handy indeed!
thanks shelton. |
np, north islander!
being Australia Day 'n' all :) my 2nd head found the answer ;) |
I also like this one:
ls * List all dirs and recurse one dir down. |
My favorite is this:
'ls -al | sed /^d/!d' This will list all the .directories, and in the format I prefer. |
Quote:
Code:
ls -al | sed '/^d/!d' The version you posted won't work with bash. Cheers, Tink |
too much typing. I usually ploink such things in an alias or function in ~/.bashrc. My most recent entries there were
Code:
alias lrt="ls -lrt" alias cdl="cd $1; ls --color=auto" |
All times are GMT -5. The time now is 04:44 PM. |