How to delete over 100,000 files with rm

Ever tried to delete 100,000 files with rm? Got the following error message?

/bin/rm: Argument list too long.

Heh yeah me too.

Here is the solution: (lets say you want to delete all files that end with .mbox)

find . -name ‘*.mbox’ -print0 | xargs -0 rm

Recently my mail server went out of control, the end result, thousands of duplicate emails.

Leave a Reply