In some cases that you have hundreds of thousands or even millions 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 a command like rm -rf *.*
is replaced with the list of all files, and usually, the memory buffer allocated to shell is small to accommodate let’s say millions of file names.
To solve this issue, I usually use this simple command:
find . -type f -delete
One reply on “Fast Way of Deleting Large Number of Files”
You can also do this:
ls -1 | wc -l && time find . -type f -delete
It will show how many files will be deleted and the time it takes to delete them.