Content with Style

Web Technique

How to delete files when argument list is to long ...

by Pascal Opitz on August 12 2008, 11:42

I had trouble with deleting files, because a simple

rm -Rf *

would fail because the argument list was to long.
Tom , my former co-worker from Redwire times, pointed out that I should utilize xargs.

A simple

ls | xargs rm -f

took quite a while, but did the trick!

Comments

  • Thanks. Very useful and timely—needed that just today :)

    by Anup on August 13 2008, 08:22 #

  • Man, so damn handy – I needed this the other day haha… :P

    by Simon Plenderleith on August 15 2008, 04:42 #

  • Basically it was, well still is actually, a cache folder that fills up over time and never gets emptied by the system. I spent quite a while to figure out what was using up all my space on the box, and was flabbergasted to find it in form of thousands and thousands of little cache files. Emptying this folder took about an half hour or so …

    by Pascal Opitz on August 21 2008, 11:12 #

  • What amount of files or deep folder structure was this? I just don’t remember that I’ve ever been in a situation like this?!

    by Matthias on August 19 2008, 18:05 #