/bin/rm: Argument list too long.

Have you ever encountered this particular messages? don’t know what to do with it? I used to get this a lot on some of the freeBSD server that I maintain, mostly cause when I try to delete the sendmail queue’s, my sendmail realy like to fill up the /var/spool partition :p so from time to time I have to delete it manually, but the thing is the folder contain to many files when I try to rm -fr * nasty “/bin/rm: Argument list too long.” show up. Well the solution is fairly simple (for me that is) for me just use some shell script magic:

1st I make sure I’m in the /var/spool/mqueue, so we don’t want accidentally delete the / partition don’t we?, trust me I happen to me once good thing I run it on my VMware machine if not I’ totally fsck :p. So back to our folder /var/spool/mqueue that is, I just issued this single line of shell script:

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

and all the thousand files in /var/spool/mqueue is gone! there some other way to delete multiple files here a good example how with a different approach :

find . -name '*' | xargs rm

where “.” is the current directory the command is being run

-EOF

Posted under: BSD/unix, Linux

Tagged as: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

hero ;) :| :x :twisted: :tido: :tensen: :swt: :spot: :sleepy: :shock: :run: :roll: :pasrah: :oops: :o :nono: :nangis: :muzik: :mrgreen: :mabuk: :lol: :kerek: :joget: :idea: :hedban: :evil: :desk: :cry: :cayo: :bored: :blur: :arrow: :amok: :P :D :?: :? :33: :32: :31: :30: :29: :28: :27: :26: :25: :24: :23 :22: :21: :20: :19: :18: :17: :16: :15: :13: :12: :11: :10: :09: :08: :07: :06: :05: :04: :03: :02: :01: :) :( :!: 8O 8)