Use “rm” to delete files, a lot of files

The other day when I use Xenu to check the broken links the /tmp directory was quickly filled up. When I tried to remove the temporary files using “rm *” command I was told “bach:/bin/rm Argument list too long”. Apparently there is a max number of files that rm can handle.

A little bit search on the web yielded this following solution:

use the find command and xargs, the file can be removed one by one. Like this in my case:

find . -name ‘sess_*’ | xargs rm

Since find command can also look for files with certain age, it is a great way to clean up files in this way.

This entry was posted in linux goodies. Bookmark the permalink.

One Response to Use “rm” to delete files, a lot of files

  1. Bono says:

    Thx dude, it worked very well.

    One fine point though, when using any flavour of linux, the user may have to retype the apostrophes, because the terminal is getting some other type of apostrophe, not the inverted or usual one…

Comments are closed.