Categories
utilities

How to remove large no of files

You just wanted to remove a directory with large no of files in it and you issued the command

$rm -rf *

But the rm throws an error argument listĀ  too long, then how to removeĀ  the files?

Here is a simple fix that will allow you to remove large no of files easily..

First copy and paste the below code in the terminal

function large_rm() { while read line1 ; do rm -f ./$line1; done; };

Then cd to that directory where you need to remove the files then issue the command

ls -l |large_rm

Thats it.. it will remove all the files in that directory within seconds :)