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.