/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
  • Capturing Realmedia RM Streams to a file on Disk There is a lot of software out there that can capture realmedia online streams for a fee. I've found a way in linux to do the same without buying third party software. The main motivation for this is I discovered SBS (an Australian broadcaster) provides audio news programs (1 hour......
  • Apple Mac OS X Not Accepting Login So, there it is an Apple Mac configured to auto login is now showing a Login screen and it doesn't seem to like any of the usernames and passwords that we could think of. In other words we're locked out. I haven't done an awful lot of Mac support, but......
  • 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......
Blog Traffic Exchange Related Websites
  • Free Help for Household and Technology Product Repairs Baby boomers typically own a lot of "stuff" around the house.  It seems that one thing or another is always in need of repair.  If its a kitchen appliance or some electronic gadget, our tendency is to just throw it away because the actual or perceived cost of repair exceeds......
  • Things to Have Removed from your Credit Report pt 2 Continued from part 1. 3 - Charge Offs. When you do not pay off a credit card account or a loan account for a period of three to six months, your creditors are generally going to assume that your account is non collectible, or that it is in default. When......
  • Frugal Vacations: Where to Find Good Cheap Hotels We've enjoyed traveling around the country mainly with some trips outside the country between us. For us, we try to get the best value in terms of what we pay and the experiences we have. We're not too big on collecting souvenirs, but rather try to get a feel for local cuisine and......
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