From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Fri, 22 Jan 2010 13:20:36 -0500 To: 9fans@9fans.net Message-ID: <547b7cc1b2f3d79169a13bc08f0b89be@coraid.com> In-Reply-To: <13426df11001221015o1d3b6c9ar9537f2777cbd11a3@mail.gmail.com> References: <13426df11001220936t6b7373d4h4d6e299aa6c74b5b@mail.gmail.com> <13426df11001221015o1d3b6c9ar9537f2777cbd11a3@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] find command reloaded Topicbox-Message-UUID: c3360564-ead5-11e9-9d60-3106f5b1d025 > I found your post a bit confusing then. The little bit of script you > posted won't do the job, and the problem is not related to find at > all, > > Anyway, while working with some hugely messy non-plan 9-software, I > found I really needed grep -r. > > See /n/sources/contrib/rminnich/grep why not just use a russ' g from p9p? - erik here's a variant: #!/bin/rc rfork e filepat='\.h$' exec g $* of my version: #!/bin/rc rfork e flags=-n re=() files=/dev/null f=1 if(~ $#filepat 0) filepat = '\.[Cbchlmsy]$' fn collect{ find $* | grep $filepat } fn collect1{ ls | grep $filepat } for(i){ if(~ $f 1 && ~ $i -*) flags = ($flags $i) if not if (~ $#re 0){ f = 0 re = $i } if not{ if(test -d $i) files = ($files `{collect $i}) if not files = ($files $i) } } if(~ $#re 0){ echo usage: g '[flags]' pattern ... >[1=2] exit usage } modre>[2=] switch($#files){ case 1 grep $flags $re `{collect1} $files case * grep $flags $re $files }