9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Replacement for find
@ 2015-09-30  8:01 Wolfgang Helbig
  2015-09-30  8:09 ` lucio
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Wolfgang Helbig @ 2015-09-30  8:01 UTC (permalink / raw)
  To: 9fans

Thanks for your answers!
But I consider it ugly, to ask for the disk usage if you just want to
recursively list all files.

And then, the man page for du(1) is missing from the distribution
	http://github.com/9fans/plan9port

If found one in the book "Plan9 the Manuals", snd edition. But neither
on the CD from the second Edition or the current one.

Greetings,
Wolfgang



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:01 [9fans] Replacement for find Wolfgang Helbig
@ 2015-09-30  8:09 ` lucio
  2015-09-30  8:11 ` Charles Forsyth
  2015-09-30 10:31 ` Brantley Coile
  2 siblings, 0 replies; 22+ messages in thread
From: lucio @ 2015-09-30  8:09 UTC (permalink / raw)
  To: 9fans

> But I consider it ugly, to ask for the disk usage if you just want to
> recursively list all files.

Find queries a lot more information than du, including what du
queries, so that's purely aesthetic.

You'll find "walk" as well as my own "stat" on "sources", if you can
get to it.  I'm not sure if there are copies elsewhere.

My stat is mostly correct, but too ambitious to be bug-free.  I think
the man pages it comes with describe its failings.

Lucio.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:01 [9fans] Replacement for find Wolfgang Helbig
  2015-09-30  8:09 ` lucio
@ 2015-09-30  8:11 ` Charles Forsyth
  2015-09-30  8:23   ` hiro
  2015-09-30 13:20   ` erik quanstrom
  2015-09-30 10:31 ` Brantley Coile
  2 siblings, 2 replies; 22+ messages in thread
From: Charles Forsyth @ 2015-09-30  8:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

On 30 September 2015 at 09:01, Wolfgang Helbig <helbig@mailbox.org> wrote:

> But I consider it ugly, to ask for the disk usage if you just want to
> recursively list all files.
>

It probably is not ideal, even when the circumlocution is hidden in a
script.
Perhaps find's syntax and conventions could be improved, though?

[-- Attachment #2: Type: text/html, Size: 706 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:11 ` Charles Forsyth
@ 2015-09-30  8:23   ` hiro
  2015-09-30  8:27     ` lucio
  2015-09-30  9:33     ` Wolfgang Helbig
  2015-09-30 13:20   ` erik quanstrom
  1 sibling, 2 replies; 22+ messages in thread
From: hiro @ 2015-09-30  8:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm surprised you can even remember find's command line options.
If you need to optimize this cause you have a jillion files and think
du takes too long i'd suggest creating an index of all files you have,
sorted into a text file.
Then you only have to use grep filename index.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:23   ` hiro
@ 2015-09-30  8:27     ` lucio
  2015-09-30 10:34       ` hiro
  2015-09-30  9:33     ` Wolfgang Helbig
  1 sibling, 1 reply; 22+ messages in thread
From: lucio @ 2015-09-30  8:27 UTC (permalink / raw)
  To: 9fans

> i'd suggest creating an index of all files you have,
> sorted into a text file.

NetBSD irritates me every Saturday, when it announces that it has
refreshed the "locate" database.  It is the default in the
distribution.

I bet "locate" can be ported to Plan 9, I've found most of NetBSD's
base code to be very portable.

Lucio.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:23   ` hiro
  2015-09-30  8:27     ` lucio
@ 2015-09-30  9:33     ` Wolfgang Helbig
  2015-09-30  9:58       ` Aram Hăvărneanu
  2015-09-30 10:07       ` Steve Simon
  1 sibling, 2 replies; 22+ messages in thread
From: Wolfgang Helbig @ 2015-09-30  9:33 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

In Plan 9 a command is needed, that lists recursively all files. Not more and not less. The du(1) command offers too much. I do not want to list the disk usage!

The command du(1) from the second edition of plan9 only has two command line options (-a and -b size),
whereas du(1) from
	http://github.com/0intro/plan9
offers twelve options
and from 
	http://github.com/9fans/plan9port (aka Plan 9 from User Space)
eight options.
All three distributions come w/o the man page.
The Second Edition seems closest to what is needed — A du -a without the disk usage. Lets call it recurse(1). Its man page reads:
NAME:
	recurse - list recursively the file names
SYNOPSIS:
	recurse name …
DESCRIPTION
	For each directory argument print recursively the filenames in the directory, for each filename argument,
	repeat the filename.

SEE ALSO:
	ls(1)

What do you think of it?

With this, du(1) can be simplified by printing the disk usage of its arguments only.

Greetings,
Wolfgang

The sizes of the three sources differ tremendously from 
> Am 30.09.2015 um 10:23 schrieb hiro <23hiro@gmail.com>:
> 
> I'm surprised you can even remember find's command line options.
> If you need to optimize this cause you have a jillion files and think
> du takes too long i'd suggest creating an index of all files you have,
> sorted into a text file.
> Then you only have to use grep filename index.
> 




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  9:33     ` Wolfgang Helbig
@ 2015-09-30  9:58       ` Aram Hăvărneanu
  2015-09-30 10:41         ` Wolfgang Helbig
  2015-09-30 10:07       ` Steve Simon
  1 sibling, 1 reply; 22+ messages in thread
From: Aram Hăvărneanu @ 2015-09-30  9:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

https://swtch.com/lsr.c
https://github.com/4ad/mgk.ro/blob/master/cmd/lsr/lsr.go

-- 
Aram Hăvărneanu



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  9:33     ` Wolfgang Helbig
  2015-09-30  9:58       ` Aram Hăvărneanu
@ 2015-09-30 10:07       ` Steve Simon
  2015-09-30 10:55         ` Mark van Atten
  1 sibling, 1 reply; 22+ messages in thread
From: Steve Simon @ 2015-09-30 10:07 UTC (permalink / raw)
  To: 9fans


> In Plan 9 a command is needed, that lists recursively all files.
> Not more and not less.
> The du(1) command offers too much.
> I do not want to list the disk usage!

I don't feel this need, though you obviously do.
You could try:

	#!/bin/rc

	du $* | while(s=`{read})
		echo $2

NB: don't use sed or awk, they don't understand the shells
quoting convention for filenames containing frogs.

Re: usage

Rather than doing
	B `{find . --name '*.[ch]' --print}

I do this:

	du -a | grep '\.[ch]$'

find the file I am interested in in the list and plumb it,
I guess its just personal taste.

Plan9 is different and somtimes it needs a different approach.

-Steve



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:01 [9fans] Replacement for find Wolfgang Helbig
  2015-09-30  8:09 ` lucio
  2015-09-30  8:11 ` Charles Forsyth
@ 2015-09-30 10:31 ` Brantley Coile
  2 siblings, 0 replies; 22+ messages in thread
From: Brantley Coile @ 2015-09-30 10:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

It is indeed a matter of taste and aesthetics. One reason I prefer Plan 9 is the Bell Labs aesthetics, as opposed to the so called "complete" solution aesthetic of other design philosophies which are slaves to some orthogonality or other, is the small is beautiful aesthetic. I've been using Plan 9 for 25 years and find the du solution quite attractive. I subscribe to the ideas in "Cat -v considered harmful" paper by Pike and prefer to build commands out of a smaller number of primitives. 

http://harmful.cat-v.org/cat-v/unix_prog_design.pdf 

By the way, if your using p9p you already have find(1) on the system on which you're hosting the acme execution environment. 

Sent from my iPad

> On Sep 30, 2015, at 4:01 AM, Wolfgang Helbig <helbig@mailbox.org> wrote:
> 
> Thanks for your answers!
> But I consider it ugly, to ask for the disk usage if you just want to
> recursively list all files.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:27     ` lucio
@ 2015-09-30 10:34       ` hiro
  0 siblings, 0 replies; 22+ messages in thread
From: hiro @ 2015-09-30 10:34 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Plan9 it should also be possible to write a virtual overlay file
server where creation of a new file triggers the creation of an index
entry.
On linux you would use inotify for something similar.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  9:58       ` Aram Hăvărneanu
@ 2015-09-30 10:41         ` Wolfgang Helbig
  2015-09-30 10:45           ` hiro
  0 siblings, 1 reply; 22+ messages in thread
From: Wolfgang Helbig @ 2015-09-30 10:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Both of them exactly fill the gap!

Thank you for all your insidefull discussions.

Wolfgang

> Am 30.09.2015 um 11:58 schrieb Aram Hăvărneanu <aram.h@mgk.ro>:
> 
> https://swtch.com/lsr.c
> https://github.com/4ad/mgk.ro/blob/master/cmd/lsr/lsr.go
> 
> -- 
> Aram Hăvărneanu
> 




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 10:41         ` Wolfgang Helbig
@ 2015-09-30 10:45           ` hiro
  0 siblings, 0 replies; 22+ messages in thread
From: hiro @ 2015-09-30 10:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Perhaps you could optimize even more by adding a special file-listing
instruction to your CPU design.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 10:07       ` Steve Simon
@ 2015-09-30 10:55         ` Mark van Atten
  2015-09-30 11:25           ` Wolfgang Helbig
  0 siblings, 1 reply; 22+ messages in thread
From: Mark van Atten @ 2015-09-30 10:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Wed, Sep 30, 2015 at 12:07 PM, Steve Simon <steve@quintile.net> wrote:

> NB: don't use sed or awk, they don't understand the shells
> quoting convention for filenames containing frogs.

That's a good point.

Mark.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 10:55         ` Mark van Atten
@ 2015-09-30 11:25           ` Wolfgang Helbig
  0 siblings, 0 replies; 22+ messages in thread
From: Wolfgang Helbig @ 2015-09-30 11:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Where can I read more about the “shells quoting convention”.
What are those quoting convention? And about which shell are we
talking here. Plan 9s rc(1) or Unix shells?

I downloaded lsr.c from https://swtch.com/lsr.c, compiled it:
% 9c lsr.c
% ls
lsr.c
lsr.o

linked it:
% 9l lsr.o
% ls
a.out
lsr.c
lsr.o

and installed it:
% mv a.out $home/bin/lsr

all of this with the help of Plan 9 from User Space on an IMac. It works great. Next, I’ll write the manual page for it and I can forget du(1).

Here are some usages for it:
% ed `{lsr $PLAN9 | grep 'du\.c$'}
3101

% ed `{lsr $home/plan9os|grep 'du\.c$'}
5427

% ed `{lsr $home/plan92nd|grep 'DU\.C$'}
2308

This demonstrate nicely the bloat of du(1) over the times.

Greetings
Wolfgang




> Am 30.09.2015 um 12:55 schrieb Mark van Atten <vanattenmark@gmail.com>:
> 
> On Wed, Sep 30, 2015 at 12:07 PM, Steve Simon <steve@quintile.net> wrote:
> 
>> NB: don't use sed or awk, they don't understand the shells
>> quoting convention for filenames containing frogs.
> 
> That's a good point.
> 
> Mark.
> 




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  8:11 ` Charles Forsyth
  2015-09-30  8:23   ` hiro
@ 2015-09-30 13:20   ` erik quanstrom
  2015-09-30 14:32     ` arnold
  2015-09-30 14:57     ` Steven Stallion
  1 sibling, 2 replies; 22+ messages in thread
From: erik quanstrom @ 2015-09-30 13:20 UTC (permalink / raw)
  To: 9fans

On Wed Sep 30 01:12:36 PDT 2015, charles.forsyth@gmail.com wrote:

> On 30 September 2015 at 09:01, Wolfgang Helbig <helbig@mailbox.org> wrote:
>
> > But I consider it ugly, to ask for the disk usage if you just want to
> > recursively list all files.
> >
>
> It probably is not ideal, even when the circumlocution is hidden in a
> script.
> Perhaps find's syntax and conventions could be improved, though?

9atom has a relative of andrey's find.  it takes very few options.
the -d and -D options are not easily duplicated with du.

; man find

     FIND(1)                                                   FIND(1)

     NAME
          find - recursively list files.

     SYNOPSIS
          find [ -1Ddfq ] dir ...

     DESCRIPTION
          List each argument.  If the argument is a directory recur-
          sively list it's contents.  The default is to list the cur-
          rent directory.  Specifying -d prints only directories, -D
          prints only files, -f supresses warnings, while -q supresses
          quoting the output for rc(1). With -1, mount points will not
          be traversed.

     SOURCE
          /sys/src/cmd/find.c

     SEE ALSO
          du(1)

     BUGS
          Feeping creaturism.


- erik



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 13:20   ` erik quanstrom
@ 2015-09-30 14:32     ` arnold
  2015-10-01  0:06       ` sl
  2015-09-30 14:57     ` Steven Stallion
  1 sibling, 1 reply; 22+ messages in thread
From: arnold @ 2015-09-30 14:32 UTC (permalink / raw)
  To: 9fans

Is there a C level equivalent of the BSD fts(3) suite of routines?
Or even the System V ftw / GLIBC nftw suite?

I suspect that having this would save some wheel-reinvention in
these kinds of programs.

Thanks,

Arnold

erik quanstrom <quanstro@quanstro.net> wrote:

> On Wed Sep 30 01:12:36 PDT 2015, charles.forsyth@gmail.com wrote:
>
> > On 30 September 2015 at 09:01, Wolfgang Helbig <helbig@mailbox.org> wrote:
> >
> > > But I consider it ugly, to ask for the disk usage if you just want to
> > > recursively list all files.
> > >
> >
> > It probably is not ideal, even when the circumlocution is hidden in a
> > script.
> > Perhaps find's syntax and conventions could be improved, though?
>
> 9atom has a relative of andrey's find.  it takes very few options.
> the -d and -D options are not easily duplicated with du.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 13:20   ` erik quanstrom
  2015-09-30 14:32     ` arnold
@ 2015-09-30 14:57     ` Steven Stallion
  1 sibling, 0 replies; 22+ messages in thread
From: Steven Stallion @ 2015-09-30 14:57 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Somewhat late to the party, but I use the following in my profile:

fn find {du -a $* |awk '{print $2}'}

http://plan9.bell-labs.com/sources/contrib/stallion/profile

On Wed, Sep 30, 2015 at 8:20 AM, erik quanstrom <quanstro@quanstro.net> wrote:
> On Wed Sep 30 01:12:36 PDT 2015, charles.forsyth@gmail.com wrote:
>
>> On 30 September 2015 at 09:01, Wolfgang Helbig <helbig@mailbox.org> wrote:
>>
>> > But I consider it ugly, to ask for the disk usage if you just want to
>> > recursively list all files.
>> >
>>
>> It probably is not ideal, even when the circumlocution is hidden in a
>> script.
>> Perhaps find's syntax and conventions could be improved, though?
>
> 9atom has a relative of andrey's find.  it takes very few options.
> the -d and -D options are not easily duplicated with du.
>
> ; man find
>
>      FIND(1)                                                   FIND(1)
>
>      NAME
>           find - recursively list files.
>
>      SYNOPSIS
>           find [ -1Ddfq ] dir ...
>
>      DESCRIPTION
>           List each argument.  If the argument is a directory recur-
>           sively list it's contents.  The default is to list the cur-
>           rent directory.  Specifying -d prints only directories, -D
>           prints only files, -f supresses warnings, while -q supresses
>           quoting the output for rc(1). With -1, mount points will not
>           be traversed.
>
>      SOURCE
>           /sys/src/cmd/find.c
>
>      SEE ALSO
>           du(1)
>
>      BUGS
>           Feeping creaturism.
>
>
> - erik
>



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30 14:32     ` arnold
@ 2015-10-01  0:06       ` sl
  0 siblings, 0 replies; 22+ messages in thread
From: sl @ 2015-10-01  0:06 UTC (permalink / raw)
  To: 9fans

http://doc.cat-v.org/unix/find-history

sl



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  6:54 ` Mark van Atten
@ 2015-09-30  7:39   ` hiro
  0 siblings, 0 replies; 22+ messages in thread
From: hiro @ 2015-09-30  7:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

leave away the 9 if you're not running ubuntu with a plan9 theme *sigh*



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  6:26 Wolfgang Helbig
  2015-09-30  6:39 ` Alexander Kapshuk
@ 2015-09-30  6:54 ` Mark van Atten
  2015-09-30  7:39   ` hiro
  1 sibling, 1 reply; 22+ messages in thread
From: Mark van Atten @ 2015-09-30  6:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Another way:

ed `{9 du -a . | awk '{print $2}' | grep blabla.java}

Mark.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [9fans] Replacement for find
  2015-09-30  6:26 Wolfgang Helbig
@ 2015-09-30  6:39 ` Alexander Kapshuk
  2015-09-30  6:54 ` Mark van Atten
  1 sibling, 0 replies; 22+ messages in thread
From: Alexander Kapshuk @ 2015-09-30  6:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

 On Wed, Sep 30, 2015 at 9:26 AM, Wolfgang Helbig <helbig@mailbox.org> wrote:
> Hello 9fans,
> in Unix I use find() like
> $ ed `find . -name blabla.java`
>
> to edit a file in a deeply nested directory.
>
> How would you accomplish this with commands from plan9 for user space?
>
> Greetings,
>
> Wolfgang Helbig
>

One way is,

du -a | sed '/blabla.java$/!d; s/.* //'



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [9fans] Replacement for find
@ 2015-09-30  6:26 Wolfgang Helbig
  2015-09-30  6:39 ` Alexander Kapshuk
  2015-09-30  6:54 ` Mark van Atten
  0 siblings, 2 replies; 22+ messages in thread
From: Wolfgang Helbig @ 2015-09-30  6:26 UTC (permalink / raw)
  To: 9fans

Hello 9fans,
in Unix I use find() like
$ ed `find . -name blabla.java`

to edit a file in a deeply nested directory.

How would you accomplish this with commands from plan9 for user space?

Greetings,

Wolfgang Helbig



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-10-01  0:06 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30  8:01 [9fans] Replacement for find Wolfgang Helbig
2015-09-30  8:09 ` lucio
2015-09-30  8:11 ` Charles Forsyth
2015-09-30  8:23   ` hiro
2015-09-30  8:27     ` lucio
2015-09-30 10:34       ` hiro
2015-09-30  9:33     ` Wolfgang Helbig
2015-09-30  9:58       ` Aram Hăvărneanu
2015-09-30 10:41         ` Wolfgang Helbig
2015-09-30 10:45           ` hiro
2015-09-30 10:07       ` Steve Simon
2015-09-30 10:55         ` Mark van Atten
2015-09-30 11:25           ` Wolfgang Helbig
2015-09-30 13:20   ` erik quanstrom
2015-09-30 14:32     ` arnold
2015-10-01  0:06       ` sl
2015-09-30 14:57     ` Steven Stallion
2015-09-30 10:31 ` Brantley Coile
  -- strict thread matches above, loose matches on Subject: below --
2015-09-30  6:26 Wolfgang Helbig
2015-09-30  6:39 ` Alexander Kapshuk
2015-09-30  6:54 ` Mark van Atten
2015-09-30  7:39   ` hiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).