Re: ls lacking a feature?



Roger Willcocks wrote:
"Bernard Liang" <b_liang@xxxxxxxxxxxx> wrote in message news:e7usv4$29o5$1@xxxxxxxxxxxxxxxxxxxxx
how does one perform the equivalent MS-DOS's "dir /a:d" (directory listing) in *ix (say, linux)?


ls -lF | grep /

or

find -maxdepth 1 -type d -exec ls -ld {} \;

Here's the obligatory Perl solution:

perl -le 'print for grep { -d } <*>'

If you're going for shortness, this might be closer:

perl -le '-d && print for <*>'

Or if you want to go make a different compromise between keystroke
economy and readability:

perl '-le-d&&print for<*>'

I never, until just this moment, realized you could combine command
line switches and code in the same argv[] array element, but apparently
you can, and it makes sense in a weird kind of way.

But then again, this is Perl, so making sense in a weird kind of way
is par for the course.

- Logan
.


Quantcast