• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2466
  • Last Modified:

ls and its parameters

Hi...
I just need syntax for ls whereby I get a list of subdirectories also but without the files existing in it!!
0
evansnf
Asked:
evansnf
1 Solution
 
jlevieCommented:
As far as I know there's not any universal way to list only directories with "ls". It can be done easily, however, with "find". The command that you'd use would be "find path -type d -print". Most implementations of "find" allow you to leave off the "-print", that being the default. behaviour. By default "find" recursively descends into directory trees. On implementations that support it (GNU find for one), you can get a behaviour more like "ls" by using "find path -type f -maxdepth 1 -print". For more information, see the man pages for "find".
0
 
samriCommented:
Evansnf,

   Try
 
   # ls -Rd  

   I'm not sure how the output looks like.

  Why don't you try the du command

   # du .   <- this will give you a listing of directories within current dir along with the total size for each.  and a cummulative at the end of the listing.

   If you want just the dirname and not the figures, pipe the command to a "cut"  
   Try

   # du . | cut -d" " -f1

I hope this helps,

Samri
0
 
evansnfAuthor Commented:
Samri.... I used du.... it's what I reqd.... Thanx
0
 
lenlutzCommented:
try this
ls -Rl|egrep "^d"
this will look for a d in the first char, which all dirs have
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now