nir_s
1
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
nir_s
3
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
nir_s
6
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
c444l
7
i must admit, my skills with awk are minimal, but doesn't this make more sense?
ls -l | awk ' /^d/ {print $9}'
No problem - find is definitely the best solution to this problem, although the -maxdepth option is not portable to all flavours of UNIX.
Cheers
ZB
skar_a
11
You can use the -p option of ls command which marks directories with a slash at end.
ls -p|sed -n 's#/$##p'