ls -d does not work

Hi falks,

I need to dispaly a list of only directories .
As it written in the manual ,the command to do it is 'ls -d'.
When i issue 'ls -d' i'm getting:

tornado.orca.ent:DB10g :/home/oracle/Create_Database > ls -d
.

Is anyone have any idea why id does not display directories ,or maybe there is another switch of 'ls' to do it?

Thanks in advance,
Nir

.....

Hey druuna,

Thanks for your reply.

ls -d * is not good for me because it displays files and directories.
I need to display directories excluding files.

Any more ideas?

Nir

.....

No, that won't do it.

The command you're looking for is
ls -l /my/dir | grep '^d'

so you were almost there.... Obviously you can omit /my/dir to get a listing for the current directory.

Cheers
ZB

Hey falks,

Thanks a lot!!
Zazzybob - your suggestion was the closer to what i was looking for.
Finally ,i used the following:

ls -l | grep '^d' | awk '{print $9}'

Regards,

Nir

i must admit, my skills with awk are minimal, but doesn't this make more sense?

ls -l | awk ' /^d/ {print $9}'

,.....

No problem :wink: - find is definitely the best solution to this problem, although the -maxdepth option is not portable to all flavours of UNIX.

Cheers
ZB

Hi,
better and simply is

ls -d */

You can use the -p option of ls command which marks directories with a slash at end.

ls -p|sed -n 's#/$##p'

without sed: