How to delete a huge amount of files at once on linux

I was trying to delete a folder which tons of files and the rm command was giving me an error,
luckly the almighty find command did the job for me :)

-bash-3.2# ls -1 | wc -l
54999

Wow that’s a lot of files!

-bash-3.2# rm *
-bash: /bin/rm: Argument list too long

Yikes! Let’s try the find alternative

-bash-3.2# find . -type f -exec rm -f {} \;
-bash-3.2# ls -1 | wc -l
0

Great :)

  1. No comments yet.

  1. No trackbacks yet.