9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Is there a Plan 9 equivalent of the find command
@ 2007-06-10 19:32 Kim Shrier
  2007-06-10 19:44 ` Kris Maglione
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kim Shrier @ 2007-06-10 19:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

This is probably me just stuck in the UNIX mind set again.  I have
looked through the commands and I don't see anything that does what
find does.  What I am trying to do is look in a directory that has
many files and subdirectories and find any file that contains a string.
In UNIX, I would do something like this.

find . -type f -exec grep some_pattern {} \; -print

What is the Plan 9 way?

Thanks,
Kim


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

* Re: [9fans] Is there a Plan 9 equivalent of the find command
  2007-06-10 19:32 [9fans] Is there a Plan 9 equivalent of the find command Kim Shrier
@ 2007-06-10 19:44 ` Kris Maglione
  2007-06-10 19:44 ` erik quanstrom
  2007-06-17  7:27 ` Dan Cross
  2 siblings, 0 replies; 6+ messages in thread
From: Kris Maglione @ 2007-06-10 19:44 UTC (permalink / raw)
  To: 9fans

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

On Sun, Jun 10, 2007 at 01:32:25PM -0600, Kim Shrier wrote:
> This is probably me just stuck in the UNIX mind set again.  I have
> looked through the commands and I don't see anything that does what
> find does.  What I am trying to do is look in a directory that has
> many files and subdirectories and find any file that contains a string.
> In UNIX, I would do something like this.
>
> find . -type f -exec grep some_pattern {} \; -print
>
> What is the Plan 9 way?
>
> Thanks,
> Kim

http://plan9.bell-labs.com/wiki/plan9/FAQ/index.html#INSTALLATION_AND_ADMINISTRATION

http://plan9.bell-labs.com/wiki/plan9/UNIX_to_Plan_9_command_translation/index.html

-- 
Kris Maglione

A little humility is arrogance.

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: [9fans] Is there a Plan 9 equivalent of the find command
  2007-06-10 19:32 [9fans] Is there a Plan 9 equivalent of the find command Kim Shrier
  2007-06-10 19:44 ` Kris Maglione
@ 2007-06-10 19:44 ` erik quanstrom
  2007-06-10 20:10   ` Kris Maglione
  2007-06-17  7:27 ` Dan Cross
  2 siblings, 1 reply; 6+ messages in thread
From: erik quanstrom @ 2007-06-10 19:44 UTC (permalink / raw)
  To: 9fans

there is a find in /n/sources/contrib/quanstro/find.tbz but it
does not have the options you show.  they way it is generally
used is

	find . | grep pattern

Du(1) may also serve the same function, but it seems a bit clunkier
to me.

- erik


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

* Re: [9fans] Is there a Plan 9 equivalent of the find command
  2007-06-10 19:44 ` erik quanstrom
@ 2007-06-10 20:10   ` Kris Maglione
  2007-06-11 18:09     ` Federico Benavento
  0 siblings, 1 reply; 6+ messages in thread
From: Kris Maglione @ 2007-06-10 20:10 UTC (permalink / raw)
  To: 9fans

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

On Sun, Jun 10, 2007 at 03:44:31PM -0400, erik quanstrom wrote:
>	find . | grep pattern

There are tens of scripts in contrib which do that with du.

But the request was for something more like:

grep some_pattern */*

or

grep some_pattern `{find .}

or

find . | read -m |
ifs='
' while(l=`{sed 10q}) {
	grep -n some_pattern $l
}

-- find --
#!/bin/rc

du -a | sed 's/[^	]*	//'

-- xarg --
#!/bin/rc
rfork s

n=10
if(~ $1 -l) {
	n = $2
	shift 2
}

{read -m; echo -n 'interrupted' >/proc/$pid/notepg} |
while() {
	ifs='
'	{ l = `{sed $n^q } }
	$* $l
}

-- --

find . | xarg grep -n some_pattern

-- 
Kris Maglione

Roses are red violets are blue
I am schizophrenic and so am I

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: [9fans] Is there a Plan 9 equivalent of the find command
  2007-06-10 20:10   ` Kris Maglione
@ 2007-06-11 18:09     ` Federico Benavento
  0 siblings, 0 replies; 6+ messages in thread
From: Federico Benavento @ 2007-06-11 18:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I use russ' lsr, so lsr | grep pattern

http://swtch.com/lsr.c

--
Federico G. Benavento


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

* Re: [9fans] Is there a Plan 9 equivalent of the find command
  2007-06-10 19:32 [9fans] Is there a Plan 9 equivalent of the find command Kim Shrier
  2007-06-10 19:44 ` Kris Maglione
  2007-06-10 19:44 ` erik quanstrom
@ 2007-06-17  7:27 ` Dan Cross
  2 siblings, 0 replies; 6+ messages in thread
From: Dan Cross @ 2007-06-17  7:27 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Back in the day, I wrote two commands: walk and sor.  Walk was
somewhat similar to Russ's lsr command (these days, lsr would probably
be better; the only additional thing walk offered was the ability to
limit the depth of searching via an option).  Sor took other commands
as arguments; for each filename that it read (presumably generated by
walk), it would apply each test successively; if one returned `true'
it would print out the resulting filename.  (sor, incidentally, stands
for `stream or').

The idea behind find, when you step back a little bit, is to produce
some list of files (or otherwise do something interesting with them)
after applying a set of predicates to them.  The predicates can be
strung together into aribrary sequences that form filters based on the
boolean value of evaluating the predicates for each file that find
visits.  Well, in Plan 9, we form filters that reduce lists using
pipes, and sor was just a convenient way to compute the boolean or of
a bunch of predicate evaluations.  It worked out, I thought,
reasonably well, but never made it into the distribution; I guess no
one else saw the point.  But, if you search through the 9fans
archives, you can probably find the tools (and they're in my contrib
directory on sources).  I still thing it's mostly an improvement.

        - Dan C.

On 6/10/07, Kim Shrier <kim@tinker.com> wrote:
> This is probably me just stuck in the UNIX mind set again.  I have
> looked through the commands and I don't see anything that does what
> find does.  What I am trying to do is look in a directory that has
> many files and subdirectories and find any file that contains a string.
> In UNIX, I would do something like this.
>
> find . -type f -exec grep some_pattern {} \; -print
>
> What is the Plan 9 way?
>
> Thanks,
> Kim
>


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

end of thread, other threads:[~2007-06-17  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-10 19:32 [9fans] Is there a Plan 9 equivalent of the find command Kim Shrier
2007-06-10 19:44 ` Kris Maglione
2007-06-10 19:44 ` erik quanstrom
2007-06-10 20:10   ` Kris Maglione
2007-06-11 18:09     ` Federico Benavento
2007-06-17  7:27 ` Dan Cross

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).