?

Log in

No account? Create an account

linux 'ls' question

« previous entry | next entry »
Apr. 1st, 2007 | 09:32 am
mood: busybusy

so, let's say I want to see only the directories, not files, in the current directory. only the names, not their contents.

is there an option to 'ls' for that? I can't seem to come up with one.

Bonus: Also, don't show me any of the hidden (beginning with a dot) folders.

This would work, except that I want the output in the normal-looking ls - C style columns:
ls -F | grep /

This is what I came up with (in bash), but there must be a better way:
find -maxdepth 1 -type d -name '[!.]*' -printf '%f ' | xargs ls -d 2>/dev/null

Link | Leave a comment |

Comments {14}

Chef Monkey

Re: and one might think

from: chefmonkey
date: Apr. 2nd, 2007 03:35 pm (UTC)
Link

Of course, that was me. If you reply, reply to this -- otherwise I'll likely not see the reply.

Reply | Parent | Thread

JP Sugarbroad

Re: and one might think

from: taral
date: Apr. 3rd, 2007 02:00 am (UTC)
Link

I'd do this:

echo */ | sed -e 's,/,,g' | xargs ls -d

Reply | Parent | Thread

Chef Monkey

Re: and one might think

from: chefmonkey
date: Apr. 3rd, 2007 02:09 am (UTC)
Link

Ah, yes! Much lighter weight. One built-in and three externals instead of four externals. Bravo.

Reply | Parent | Thread

Triple Entendre

Re: and one might think

from: triple_entendre
date: Apr. 3rd, 2007 02:21 am (UTC)
Link

I like it, but for some reason echo */ doesn't work in my bash shell, nor with /bin/echo.

echo *, on the other hand, behaves like one would expect. But this doesn't help us here. Hmmm....

Reply | Parent | Thread

Triple Entendre

Re: and one might think

from: triple_entendre
date: Apr. 3rd, 2007 02:23 am (UTC)
Link

because, duh, I was running it in a directory which contained only files.

Reply | Parent | Thread

JP Sugarbroad

Re: and one might think

from: taral
date: Apr. 3rd, 2007 04:50 am (UTC)
Link

Ahahahaha.

Reply | Parent | Thread

JP Sugarbroad

Re: and one might think

from: taral
date: Apr. 3rd, 2007 04:50 am (UTC)
Link

If echo */ doesn't work, how come ls */ does?

Reply | Parent | Thread