hyuri: (Default)
[personal profile] hyuri
why is find . | grep pattern faster than find -name pattern?

Date: 2010-02-28 12:33 am (UTC)
From: [identity profile] rizen.livejournal.com
I'm guessing that you tried find on its own first, and then tried find | grep?

Date: 2010-02-28 01:31 am (UTC)
From: [identity profile] hyuri.livejournal.com
Actually no. Being somewhat familiar with grep, I started piping find's output as a general practice as soon as I discovered (several years ago) that it would output a list of everything below a given tree point. I only noticed that find alone was slower today when I actually read the man page, figured out the -name options, and decided to try it.

Piping through grep seems to be more flexible as well, though I may have missed some options somewhere in my cursory read.

Date: 2010-02-28 03:32 am (UTC)
From: [identity profile] rizen.livejournal.com
Well, I meant in direct temporal order, rather than long-term.

I've noticed that grepping and such are much, much faster after the first attempt, which I expect means that the OS has cached these files in available memory. (And this is why I'd *love* an SSD.)

Date: 2010-02-28 04:59 am (UTC)
From: [identity profile] hyuri.livejournal.com
Yeah, I wasn't really clear there. I ran find|grep -i first, then thought about it and looked at the man page, then ran find -iregex. So if anything, find alone should have benefitted from the caching....

Hell, I dunno. Maybe it's just another instance of my computers screwing with me.

Profile

hyuri: (Default)
hyuri

November 2014

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 24th, 2026 06:21 am
Powered by Dreamwidth Studios