Geek Projects – Linux, Apache, MySQL, PHP, DNS A Linux Sysadmin

March 2, 2009

Bypass rm's “argument list too long” error message with xargs

Filed under: Linux — Tags: , , — Matt @ 3:19 pm

When using rm to delete a large number of files, you may come up against a kernel limitation which limits the length of arguments that can be sent to rm:

$ rm *

bash: /bin/rm: Argument list too long

This one-liner utilizes xargs to bypass this limitation:

ls | xargs rm

Powered by WordPress