Today I try to delete a directory with 485,000+ files on Linux server. It shows the error message below.

If you’re trying to delete a very large number of files in a single directory at one time, you will probably run into this error. The problem is that when you type something like rm -f /data/*. So how do we working with directories with a large number of files? Let talk about it below.

## Show first files

To show first n files in the directory instead of to show all files.

## Remove files

### Using Find

Using find -delete. (2000 files/second, it is about three time faster rm)

Using find and xargs. To find every file and pass them one-by-one to the “rm” command (not recommend, xargs is dangerous*)