⚠️ Warning: This post is over a year old, the information may be out of date.

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

📅 | ⏰ 0 minutes

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

# 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
view raw find.sh hosted with ❤ by GitHub

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  ↩︎

Posted by: Robbi Nespu

Edit

Have some thoughts, discussion or feedback on this post?

💬 Send me an email

What is webmention? How to send interactions!

Below you can find all of webmention with this page. Which means, you also can mentioned this URL on any website that support WebMention. Have you written a response to this post? Let me know the URL:

Do you use a website that don't have WebMention capabilities? You can just use Comment Parade!