From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16775 invoked from network); 6 Jan 2022 10:08:08 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 6 Jan 2022 10:08:08 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 4ess; Wed Jan 5 20:43:14 -0500 2022 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 171ae8be (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Wed, 5 Jan 2022 17:36:01 -0800 (PST) Message-ID: To: 9front@9front.org Date: Wed, 05 Jan 2022 20:35:59 -0500 From: ori@eigenstate.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: proven browser extension CMS locator Subject: Re: [9front] [PATCH] g: use xargs instead of finding complete file list before greping Reply-To: 9front@9front.org Precedence: bulk Quoth Michael Forney : > On 2022-01-04, igor@9lab.org wrote: > > xargs also has a parallel mode that comes in handy to speed up search > > in this case. > > Is there a possibility that this might result in intermixed grep > results (i.e. one process printing a line in the middle of a another > line)? That'd be my main concern with adding parallelism to xargs. > > > case * > > - pattern=$1 > > - shift > > for(f in $*){ > > if(test -d $f) > > - files=($files `$nl{walk -f $recurse -- $* \ > > - | grep -e $fullnames -e $suffixes >[2]/dev/null}) > > + walk -f $recurse -- $f \ > > + | grep -e $fullnames -e $suffixes >[2]/dev/null > > if not > > - files=($files $f) > > + echo -n $f$nl > > If we don't care about ordering of results, we could also skip the > for-loop completely and replace this entire case with > > walk -f -n0 -- $* > walk -f $recurse -- $* | grep -e $fullnames -e $suffixes >[2]/dev/null > > and change the default to recurse='-n1,'. This would walk all named > file arguments first, followed by the files in the directories. > And if we do, we can |sort at the end, which means the results won't trickle in, but it will be sorted. I'd prefer that.