<div dir="ltr"><div>I've switched to this syntax instead of find|xargs:</div><div><br></div><div>find . -type f -exec grep whatever {} +</div><div><br></div><div>Or, mostly I just use:</div><div><br></div><div>ack whatever<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 12, 2022 at 2:44 PM alan schmitz <<a href="mailto:alan.schmitz88@gmail.com">alan.schmitz88@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>That is great info, thank you!  One test I ran a long time ago wrt find is the difference between:</div><div>find . -type f -exec grep notLklyToBeFnd {} \;</div><div>vs.</div><div>find . -type f | xargs grep notLklyToBeFnd</div><div><br></div><div>I'm not sure if it holds today, but when I ran it back then the xargs version was much faster than the -exec.  Of course that was a very long time ago.</div><div><br></div><div>Alan<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 12, 2022 at 1:58 PM Brian Sturgill <<a href="mailto:bsturgill@ataman.com" target="_blank">bsturgill@ataman.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I said I didn't know how fast PWSH's Select-String (grep) method was, but intend to run some</div><div>benchmarks. The discussion evolved into 'grep -r' vs 'find ... -exec grep pat {}...).</div><div><br></div><div>Here's some benchmarks.</div><div>They are run on my main Linux and Windows desktop machines.<br></div><div>Windows box slightly more powerful than the Linux box.</div><div>Windows 11th gen i7 laptop chip [Intel nuc] w/32gb memory.</div><div>Linux 8th gen i5 (8th gen, but recently reengineered... about as fast as 11th gen, somewhat worse power consumption), 16 gb mem.<br></div><div>Both have good M.2 SSDs.<br></div><div>My Linux version is Ubuntu 21.10 Mate.<br></div><div>My Windows version is the latest stable build of Windows 11.<br></div><div><br></div><div>I ran these commands on the same set of 6+GB of ebooks.<br><br></div><div>Commands benchmarked:<br></div><div>"rgrep": grep -r notLklyToBeFnd .</div><div>"find" find . -type f -exec grep notLklyToBeFnd {} \;</div><div>"pwsh": Get-ChildItem -Path "." -Recurse | Select-String -Pattern "notLklyToBeFnd" -CaseSensitive</div><div><br></div><div>All times are in seconds.</div><div><br></div><div>Linux machine, using bash and pwsh (cross-platform version of Microsoft PowerShell)</div><div>"rgrep"   3.1<br></div><div>"find"     5.5<br></div><div>"pwsh"   90</div><div><br></div><div>Windows machine using cross-platform PowerShell and bash in WSL 2.0):</div><div>"rgrep"  4.6<br></div><div>"find"     50</div><div>"pwsh"   84<br><br></div><div>I also tried it the older Windows/only variant of Powershell where "pwsh" took about 120 seconds.<br><br></div><div>The problem with with "pwsh" seems to be with the "Select-String" command. On a large PDF file it took 600 milliseconds. Grep took only 27 milliseconds.<br><br></div><div>Note that the "rgrep" times were similar between my native linux box and WSL 2.0.<br></div><div>But that the "find" one was 10x greater. I think the issue may be a caching issue between Ubuntu in WSL 2 and the Windows file system. The Ubuntu on WSL 2.0 may be giving up blocks quickly to avoid double caching... this hurts when using find to repeatedly start grep. My theory is that the grep code has to get copied back into the Ubuntu address space every time grep starts again.<br></div><div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>Brian</div><div> <br></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div>