22 August 2014

What's the faster way to delete files in linux: find -delete or rm -rf ?

I was wondering what's faster in deleting files: find or rm ?

root@gw:~/test# ls | wc -l
879874


root@gw:~# time rm -rf test/

real 0m23.545s
user 0m0.848s
sys 0m9.684s

---

root@gw:~# time find ./test/ -delete

real 0m41.667s
user 0m0.352s
sys 0m11.644s

---

root@gw:~/# time find ./test/ | xargs rm -rf

real 0m41.005s
user 0m0.968s
sys 0m11.824s

---

root@gw:~/# time rm -rf ./test/*
- I stopped it after 120 seconds, bash was using one CPU core.