Terminal

Fast Way of Deleting Large Number of Files

Submitted by str on Tue, 08/28/2012 - 11:23

In some cases that you have hundred of thousands or even million of files in a directory that you want to delete, you will encounter this error:
/bin/rm: Argument list too long.

The problem is when you type command like rm -rf *, * is replaced with the list of all files, and usually the memory buffer allocated to shell is small to accomodate let's say million of file names.

To solve this issue, I usually use this simple command:

find . -type f -delete