JOURNAL.ROBBI.MY
← Back to Posts

Posix - Speed up "find" + "exec" command (recursive)

article 1 min read

I learn some trick today on how to speed up find, exec command. Let check this out:

gist Β· RobbiNespu View on GitHub β†—
# let see how many files we have
$ find . -type f | wc -l
36367

# lets check every file status
$ time find . -type f -exec stat {} \; > /dev/null
real    0m40.107s
user    0m14.381s
sys     0m26.410s

# lets check every file status
$ time find . -type f -exec stat {} + > /dev/null
real    0m1.281s
user    0m0.626s
sys     0m0.656s

Wow that’s quite a huge difference! Impressive! All we did was swap the \; for a +.

Explanation? You may refer here1


  1. Martin Tournoij [Carpetsmoker], arp242.net/make-find-exec-faster.html ↩︎

Have some thoughts, discussion or feedback on this post?

β–Έ What is webmention? How to send interactions!
Below you can find all of webmention with this page. You can also mention this URL on any website that supports WebMention. Have you written a response to this post? Let me know the URL:

Don't have WebMention? Use Comment Parade!

No webmentions yet.

Comments section coming soon. For now, send a webmention or email.