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

About these ads

~ 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

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

 
Follow

Get every new post delivered to your Inbox.

Join 1,372 other followers

%d bloggers like this: