rc3.org

Since 1998.

rc3.org header image 1

Too much mail

December 15th, 2006 · 3 Comments

You know what happens when you never empty your trash? You wind up with 211,000 email messages in your trash folder and your mail server freaks out. (Most of the 211,000 are, of course, trashed spam.)

If you have too much mail in your folder, you run into the following:

$ rm * -bash: /bin/rm: Argument list too long

The solution is to use find like this:

$find . -type f | xargs rm

Of course, find is recursive, so be careful if you have any subdirectories in that directory.

3 responses so far ↓

  • 1 Erik Kastner // Dec 15, 2006 at 11:24 am

    Put -maxdepth 1 after “-type f” and it will not recurse

    Thanks for writing this down, I nomrally have to “rediscover” this every few months.

  • 2 Daniel // Dec 16, 2006 at 3:22 am

    Why not:

    ls | xargs rm

    Although it doesn’t include hidden files, and using ‘ls -a’ is dangerous since it will list ‘..’.

  • 3 dbt // Dec 20, 2006 at 1:27 pm

    Why not rm -r subdir?

Leave a Comment

You can comment using OpenID:

Or you can just enter your personal information and comment that way. Your email address is required but won't be displayed.

Please enter your comment. Markdown is supported.