Re: ls lacking a feature?



Bernard Liang said:

Well,

....you just want the directory name, not all the gubbins, so you thought
you'd try:


ls -l | grep ^d | tr -s ' ' | cut -d' ' -f9

This is slightly shorter:

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

seems to do the trick for me, but this is a very cheap hack,

Yes.

and is
dependent on what fields ls decides to print.

Yes.

I am definitely not
convinced this is the best method, but unfortunately this is the
simplest one I know that works.

It's fairly easy to write a C program to do this, if nobody comes up with a
better idea - and such a program would /not/ rely on the fields ls decides
to print.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.