Linux: RM Files Using xargs. Another: Argument list too long

Here is another example of removing files from a Linux system when faced with error Argument list too long. This time, I was trying to remove log files from an ESX cluster after a few core dumps and ISCSI problems.

To start, here is the failed command
# rm -f `find /vmfs/volumes/ -ctime 3 | grep “.log” | grep “vmware-”`
-bash: /bin/rm: Argument list too long

Here is the total file count that I needed to be removed
# find /vmfs/volumes/ -ctime 3 | grep “.log” | grep “vmware-” | wc -l
4982

The successful command string using xargs
# find /vmfs/volumes/ -ctime 3 | grep “.log” | grep “vmware-” | xargs rm

~ by Kevin Goodman on November 15, 2008.

One Response to “Linux: RM Files Using xargs. Another: Argument list too long”

  1. [...] http://blog.colovirt.com/2008/11/15/rm-files-using-xargs-another-argument-list-too-long/ Possibly related posts: (automatically generated)Working with Files and Directory [...]

Leave a Reply