Argument list too long – Workarounds

by damonp on December 28, 2006

Trying to clean out my SPAM folder:

[root@atlas cur]# rm -f *
-bash: /bin/rm: Argument list too long

Try this:

for x in *; do rm -f $x; done

Or:

find . -name '*' -print0 | xargs -0 rm

Popularity: 3% [?]

{ 2 comments… read them below or add one }

Chris January 7, 2007 at 3:24 pm

Much better than the for-loop:

ls | while read f; do rm $f; done

Reply

damonp January 22, 2007 at 12:41 pm

The ls way is clean, but I like using find so you can only select certain messages. With my SPAM mailbox, I can delete messages that are older than a specified period of time (ie. 14 days below).

[code lang="bash"]find . -mtime 14 -print0 | xargs -0 rm[/code]

Reply

Leave a Comment

Previous post:

Next post: