Re: ls lacking a feature?



Bernard Liang wrote:
Well,

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

seems to do the trick for me, but this is a very cheap hack, and is
dependent on what fields ls decides to print.

Many bits of Unix shell programming are cheap hacks.
For GNU ls the fields are unlikely to change, since so many other
programs rely on their format. The same is true for many other lses
though they may have slightly different formats.

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

I would do it using the "find" method already posted, putting it into a
bash subroutine in my .bashrc file, or a separate bash script.

-BL

Richard Heathfield wrote:

Bernard Liang said:


how does one perform the equivalent MS-DOS's "dir /a:d" (directory
listing) in *ix (say, linux)?


I use:

ls -al | grep ^d

but there's probably an easier way. :-)


.