/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
  • Converting spaces in filenames to underscores Linux supports long file names, in some (many?) ways better than windows. However, when I moved over to linux I had tons of files with spaces in the name. This isn't really a problem usually, but it can be a bit annoying having to enclose the filename in quotes for......
  • 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......
  • The 2nd journey begins… Mandriva 2006 upgrade 2 - Part 9 Still running the qemu image (and downloaded another image from the freeoszoo while I was waiting for the installer.) Anyway... I've turned my attention to mythtv and since it's the same version went to test if it was working well. Let's see... for starters, since the local machine had seen......
Blog Traffic Exchange Related Websites
  • 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......
  • 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......
  • 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......
www.pdf24.org    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