* Listing Directories (without files!)
@ 2000-03-20 5:00 Mark M.
2000-03-20 5:00 ` Andy Wagg
0 siblings, 1 reply; 5+ messages in thread
From: Mark M. @ 2000-03-20 5:00 UTC (permalink / raw)
Currently I use the following command on our Digital Alphastation 4/166's
(with OSF/1) to obtain a listing of subdirectories without the associated
clutter of file names:
ls -p | grep "/"
This command uses "-p" to place a "/" at the end of each directory name,
(but not file names), then searches for and displays only those entries with
a "/", yielding a display of only the subdirectories. I do this because the
directory has about 50,000 files in it and I have no other brief method of
displaying just the directory names.
QUESTION: IS THERE A BETTER WAY? Is there an "ls" option that does this?
Mark M.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Listing Directories (without files!)
2000-03-20 5:00 Listing Directories (without files!) Mark M.
@ 2000-03-20 5:00 ` Andy Wagg
2000-03-20 5:00 ` Knut Hellebø
0 siblings, 1 reply; 5+ messages in thread
From: Andy Wagg @ 2000-03-20 5:00 UTC (permalink / raw)
Why not use find:
find / -type d -print
This should give you a nice list of all the directories.
Andy.
"Mark M." wrote:
> Currently I use the following command on our Digital Alphastation 4/166's
> (with OSF/1) to obtain a listing of subdirectories without the associated
> clutter of file names:
>
> ls -p | grep "/"
>
> This command uses "-p" to place a "/" at the end of each directory name,
> (but not file names), then searches for and displays only those entries with
> a "/", yielding a display of only the subdirectories. I do this because the
> directory has about 50,000 files in it and I have no other brief method of
> displaying just the directory names.
>
> QUESTION: IS THERE A BETTER WAY? Is there an "ls" option that does this?
>
> Mark M.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Listing Directories (without files!)
2000-03-20 5:00 ` Andy Wagg
@ 2000-03-20 5:00 ` Knut Hellebø
2000-03-20 5:00 ` Mark M.
2000-03-21 5:00 ` Yong S. Yi
0 siblings, 2 replies; 5+ messages in thread
From: Knut Hellebø @ 2000-03-20 5:00 UTC (permalink / raw)
Hi !
I've always been doing ls -ld *|grep '^d' with success. Think this is
faster than find if you're only wanting to investigate the current
directory. You could also do a find -prune .... where prune makes the
find command not descending into subdirectories (if I remember right).
Knut Helleb�
Merkantildata ASA
Bergen, Norway
Andy Wagg wrote:
>
> Why not use find:
>
> find / -type d -print
>
> This should give you a nice list of all the directories.
>
> Andy.
>
> "Mark M." wrote:
>
> > Currently I use the following command on our Digital Alphastation 4/166's
> > (with OSF/1) to obtain a listing of subdirectories without the associated
> > clutter of file names:
> >
> > ls -p | grep "/"
> >
> > This command uses "-p" to place a "/" at the end of each directory name,
> > (but not file names), then searches for and displays only those entries with
> > a "/", yielding a display of only the subdirectories. I do this because the
> > directory has about 50,000 files in it and I have no other brief method of
> > displaying just the directory names.
> >
> > QUESTION: IS THERE A BETTER WAY? Is there an "ls" option that does this?
> >
> > Mark M.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Listing Directories (without files!)
2000-03-20 5:00 ` Knut Hellebø
@ 2000-03-20 5:00 ` Mark M.
2000-03-21 5:00 ` Yong S. Yi
1 sibling, 0 replies; 5+ messages in thread
From: Mark M. @ 2000-03-20 5:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
Bergen Norway? My long lost relatives are out there someplace, in Seim
Norway. My Mother's maiden name is Seim. We have old photographs of those
who came to Canada many years ago. One of my brothers went there about 20
years ago to visit. When my wife and I went to England and France we checked
out the cost of going to Norway. At that time it would have costed us as
much to go to Norway from England as to get all the way to England from
Canada, so we skipped it.
Mark M.
Knut Helleb� wrote in message <38D68B81.4DFD654D@merkantildata.no>...
>Hi !
>
>I've always been doing ls -ld *|grep '^d' with success. Think this is
>faster than find if you're only wanting to investigate the current
>directory. You could also do a find -prune .... where prune makes the
>find command not descending into subdirectories (if I remember right).
>
> Knut Helleb�
> Merkantildata ASA
> Bergen, Norway
>
>Andy Wagg wrote:
>>
>> Why not use find:
>>
>> find / -type d -print
>>
>> This should give you a nice list of all the directories.
>>
>> Andy.
>>
>> "Mark M." wrote:
>>
>> > Currently I use the following command on our Digital Alphastation
4/166's
>> > (with OSF/1) to obtain a listing of subdirectories without the
associated
>> > clutter of file names:
>> >
>> > ls -p | grep "/"
>> >
>> > This command uses "-p" to place a "/" at the end of each directory
name,
>> > (but not file names), then searches for and displays only those entries
with
>> > a "/", yielding a display of only the subdirectories. I do this because
the
>> > directory has about 50,000 files in it and I have no other brief method
of
>> > displaying just the directory names.
>> >
>> > QUESTION: IS THERE A BETTER WAY? Is there an "ls" option that does
this?
>> >
>> > Mark M.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Listing Directories (without files!)
2000-03-20 5:00 ` Knut Hellebø
2000-03-20 5:00 ` Mark M.
@ 2000-03-21 5:00 ` Yong S. Yi
1 sibling, 0 replies; 5+ messages in thread
From: Yong S. Yi @ 2000-03-21 5:00 UTC (permalink / raw)
Knut Helleb^x wrote:
> I've always been doing ls -ld *|grep '^d' with success. Think this is
> faster than find if you're only wanting to investigate the current
> directory. You could also do a find -prune .... where prune makes the
> find command not descending into subdirectories (if I remember right).
Why `ls -ld *|grep ...`? Why not `ls -l|grep ...`?
Even though the two would do the same thing (minus the 'total'
difference with `ls -l` vs `ls -ld *`), a directory with lots of files
(which includes 50,000) wouldn't work quite right with this, AFAIK. The
shell (depending on how your system is configured) would have to expand
the '*', and complain that there are too many arguments. Try it, you'll
see.
If that doesn't bother you enough, simply the fact that the shell would
have to expand the '*' would be another step, hence taking longer. Why?
When you use '*', it would mean that the shell would have to read the
directory once to expand it. Then ls would have to do it again, etc.
So the fastest way? Code something yourself.
-y.
--
Yong S. Yi KeyID 1024/8B4FF151 http://www.async.org/~ysyi/
PGP Key Fingerprint = 3A 65 AE 82 07 2A EF 73 0B 84 67 5D 1D 96 9F 8D
<ysyi@alf.dec.com> Enriched, VCard, and HTML messages > /dev/null
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-03-21 5:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-03-20 5:00 Listing Directories (without files!) Mark M.
2000-03-20 5:00 ` Andy Wagg
2000-03-20 5:00 ` Knut Hellebø
2000-03-20 5:00 ` Mark M.
2000-03-21 5:00 ` Yong S. Yi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox