Little Nugget of Wisdom #235: /bin/rm: Argument list too long - oh my!

Joeri Poesen //

When you have too many files in a given directory, and want to delete them all using *rm*, you can get presented with:

/bin/rm: Argument list too long

Crap. What's happening here? Basically *rm* uses a 128K buffer for its operations, but if the list of files (argument list) is too long to fit into that buffer: tough luck.


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

Voila. All gone.

Hat tip: John Simpson.