-bash /bin/rm: Argument list too long

Have you ever experienced that you remove command can’t remove anything, its just replies you with error. What happens when all of a sudden your command rm can not remove anymore? What else command you can use to remove? At some point in your Linux life you’ll come across a directory of session files (or something similar) that you want to remove. But, when you try to remove the files with linux’s rm command you’re met with the error message:

$ rm -rf *
$-bash /bin/rm: Argument list too long.

Well, you might try this command instead:

$ find . -type f -delete
(The find command is much quicker at listing files from a directory, and newer versions of “find” have -delete built in, which will allow you to remove files very quickly.)

Example:
Let’s say we’re looking to delete files named session_848938, session_45949343, session_454344, etc.. and they live in /path/to/files/

$ find /path/to/files/ -name “session_*” -delete

If you are absolutely sure that you want to remove everything in the directory use xargs. This is much more efficient.

$ find . -name ‘session_*’ | xargs rm

Good Luck~

jonboy60

I’m a Malaysian, my name is Jon Loh (jonboy60) living in Kuala Lumpur and working in Petaling Jaya, Malaysia. Jonboy60.com is a blog magazine about Linux and other open source softwares. All about to a daily jobs or real life experiences I had since the year 2002 administrating Linux and Windows server in a hosting company. Basically i will be offering Linux tips, howto, tricks, latest news and tutorial. Contact Me for Career opportunities, business offers, Linux solutions for business or home, web and email server solutions, Linux consulting and expertise requests. Email to me on jonboy60{@}gmail.com. The site I’m running is VenCouture.com – Malaysia Online Fashion Shopping Boutique, VenCouture. We sell fashion clothes, sexy lingeries, baby clothing and etc.

More PostsWebsite

Follow Me:
TwitterFacebook

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

*


5 + = 12

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge