From: Jon LaBadie on
aioe wrote:
> Is there some way to use the ls command that is equivalent to
> "find . -type d" ? If not, what is the -d option good for?

Others addressed the -d use question.

No, ls has no way of listing only specific file types.

You might consider ls -p (shows directories with a /)

Or a close equivalent of 'find . -type d' is 'ls -R | grep :$'
From: Thomas 'PointedEars' Lahn on
Barry Margolin wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Barry Margolin wrote:
>> > aioe wrote:
>> >> pk wrote:
>> >> > So, "ls -l directory" shows the files in the directory; "ls -ld
>> >> > directory" shows the properties of the directory itself.
>> >> For that, I just invoke ls -l from one level higher in the directory
>> >> tree, but I suppose -d might be useful in scripts.
>> > If you do that,
>> Do what?
>
> Use "ls -l <parent>" instead of "ls -ld <directory>".

I do not understand it like that but that to "invoke ls -l *from* one level
higher in the directory" tree means

cd .. && ls -l $directory

(or variations thereof).

>> > it shows all the other files and directories in the parent directory.
>>
>> ls -d $FOO
>>
>> shows all non-hidden files matching the value of `$FOO' starting from
>> the current directory, without descending if `$FOO' matches a
>> subdirectory.
>
> But I was responding to a post that said how he gets the attributes of a
> directory without using the -d option. You're using the -d option, so
> what does that have to do with it?

There are different ways to do this. "aioe" said that they are doing it
differently, but conceded that using the -d based approach instead might be
useful in scripts. You have ignored that concession and argued that this
would show all files when the number of files listed was not at issue.

>> > How do you do it if you just want to list the
>> > properties of that one directory? "ls -l | grep foo"?
>>
>> "Properties"? But I think I have answered that question already:
>>
>> ls -d *
>
> That shows the properties of lots of files, directories, symlinks, etc.,
> not just "that one directory". And you're using the -d option, which he
> was saying he doesn't use.

A directory has no "properties". I assumed that "content" was meant
instead, so ...


PointedEars
From: Eric on
On 2010-04-02, Thomas 'PointedEars' Lahn <PointedEars(a)web.de> wrote:
<snip>
>
> A directory has no "properties". I assumed that "content" was meant
> instead, so ...
>

$ touch y2
$ mkdir xyzzy
$ ls -ld y2 xyzzy
drwxr-xr-x 2 eric realusers 4096 2010-04-03 10:47 xyzzy
-rw-r--r-- 1 eric realusers 0 2010-04-03 10:47 y2
$

In what way does my file have properties and my directory not?

Eric
From: Thomas 'PointedEars' Lahn on
Eric wrote:

> Thomas 'PointedEars' Lahn wrote:
>> A directory has no "properties". I assumed that "content" was meant
>> instead, so ...
>
> $ touch y2
> $ mkdir xyzzy
> $ ls -ld y2 xyzzy
> drwxr-xr-x 2 eric realusers 4096 2010-04-03 10:47 xyzzy
> -rw-r--r-- 1 eric realusers 0 2010-04-03 10:47 y2
> $
>
> In what way does my file have properties and my directory not?

Mu.


PointedEars
From: Barry Margolin on
In article <2281474.yCbtlEUcBR(a)PointedEars.de>,
Thomas 'PointedEars' Lahn <PointedEars(a)web.de> wrote:

> A directory has no "properties". I assumed that "content" was meant
> instead, so ...

Of course it does. It has the same properties that ordinary files have:
owner, group, permissions, mtime/ctime/atime, size, etc. These are the
things displayed with "ls -ld <directory>".

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***