-bash: /bin/rm: Argument list too long

I accidentally created more than 50K empty files in a folder. When I tried to remove them using rm -rf *.tmp, I got the error -bash: /bin/rm: Argument list too long.

It turns out bash tries to expand the * into a full list, but that list became too long.

Here is how to delete that many files:

find . -name '*.tmp' | xargs rm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s