rm “Argument list too long” error; Applies to Linux, UNIX and Solaris

A while ago, I ran into an issue with a client’s Oracle database running on Sun Solaris; the audit_dump_dest directory was filled with an enormous number of useless log files that have not been cleared for years, and was taking up a lot of needed disk space. Attempting to use rm –rf to remove the files returned the error “Argument list too long”.

The solution was to use the following syntax while in the target directory:

find . -name ‘*.aud’ | xargs rm

In short, this command pipes the file names that matches the quoted *.aud pattern from the find command to the “rm” command.

One way to first list the files that will be deleted by the prior command, is to pipe to the “less” command instead:

find . -name ‘*.aud’ | less
There you have it.

About these ads
  1. No trackbacks yet.

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.

%d bloggers like this: