/bash/rm: argument list too long



I can’t tell you how many times I’ve seen this complaint from the bash shell when trying to remove a bunch of files. In this case, I was trying to clear a directory where log rotating had run amuck and there was a 10 second lag in typing ls ∗.gz and seeing any output…. So, I did rm ∗.gz and got bash/rm: argument list too long in response…. So, then I though I could “surgically remove” some files and shrink the list a bit… rm ∗5∗3∗2∗.gz -f; rm ∗5∗3∗1∗.gz -f, etc, etc, etc after about 4 of these it became obvious I’d need to find another way because even some of THOSE gave the “argument list too long” error. (What’s more, it looked like I was going to have to deal with files matching ∗[1-5]∗[0-9]∗[0-9]∗gz – yuck…)


I found an interesting solution on a redhat mailing list… it uses find and xargs….

find . -name ‘∗.gz’ | xargs rm

Make sure to put the single quotes around the ∗.gz…. but that has saved me about thirty minutes of trying to delete smaller blocks of files manually.

Related Posts

Blog Traffic Exchange Related Posts
  • Recording online streams (real / wma) to mp3 format (or ogg) with mplayer So, I've been looking back over my list of "scripts" that are pulling in audio from various news sources online for the onlineradiotv.com site. It's also got me doing a bit more spanish language listening than I had been. In the car, I usually use an mp3 player (the nexia)......
  • Rsync for easy (and quick) backups I've got to say, I haven't spent ENOUGH time with rsync to really be fluent in how I could put it to use.... A week or so ago I was reading this list of essential Linux software by a guy that moved from Mac OS X to linux because he......
  • Smartmontools on Windows - emailing warnings For years I've been using smartmontools on my linux-based machines. What I've absolutely LOVED about it is the advance notice I've had of hard drive failures. Two consecutive Decembers I received an email from my server claiming that a drive was dying and had time to replace them rescuing the......
Blog Traffic Exchange Related Websites
  • Hard Drive Data Recovery And Benefits Of Saving Files A hard drive data recovery is utilized to get back the important files from a corrupt or defective hard drive. The most usual issue that this occurs is when the computer is freezing up and becomes not responsive, sometimes the system is restarting continuously or the system is shutting......
  • How To Make Money on the Internet - Back to Basics I have been thinking to write this post from a couple of days, but I didn't have much time to compile all the basic ways to make money online. Today it's Sunday and I got couple of hours, so I am writing this post. This post is basically for newbies......
  • Thesis 1.7 Custom File Editor Errors Out In Wordpress 3.0 Wordpress 3.0, the much awaited wordpress release so far, finally arrived and I was excited to try to it out on my blog just like so many bloggers out there. I did and I was exploring the new features of this setup when I ran into the problem. I have......
PDF24    Send article as PDF   

Similar Posts


See what happened this day in history from either BBC Wikipedia
Search:
Keywords:
Amazon Logo

Comments are closed.


Switch to our mobile site