Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Why is find -delete faster than rm -rf?

Why is find ... -delete so much faster than rm -rf ? Specifically,

To clarify: I'm specifically asking: Why is find ./x -type d -delete && rm -rf x so much faster than rm -rf x/?

Background

There have been a few people who use similar mechanisms, like rsync.

  • There are several posts on why rm -rf is slow. For example, https://unix.stackexchange.com/questions/106133/why-is-rm-slow is probably one of the most focused ones.

  • Specifically, I've found cd dir-to-delete && find . -type d -delete followed by rm -rf dir-to-delete is extremely fast, even on large directories.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

rm -f isn't slow, but if you run it many files and you fire up a separate process per each rm, then it will be slow, because starting a process will cost you about 2ms on modern processor, and many files can be deleted in that time if you instead delete in batches, which is what find's -delete does. Alternatively, you can use xargs to run rm with a batch to pretty much the same effect.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!