unable to remove files using rm command /bin/rm: Argument list too long

I had faced issues in deleting files using rm command which caused our linux BOX struggle to work with Mysql Databases.
I came to see an nice article from simplehelp.net and thought of sharing the same. which will help to take your headache.
on my case, i had issue on deleting this mail queue which was frozen for a month
# /var/spool/clientmqueue
root@server # rm -Rf filename*
#/bin/rm: Argument list too long.

Ever seen this error in Linux when you have too many files in a directory and you are unable to delete them with a simple rm -rf *? I have run into this problem a number of times. After doing a bit of research online I came across a neat solution to work around this issue.

find . -name 'SAS*' | xargs rm

In the above instance the command will forcefully delete all files in the current directory that begin with SAS. You can replace the SAS-* with anything you like. You can also replace it with just a * if you want to remove all files in the folder.

find . -name '*' | xargs rm

Thanks who ever wrote this.

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.