Mailinglist Archive: opensuse (2459 mails)

< Previous Next >
Re: [opensuse] /bin/rm: Argument list too long
  • From: Sloan <joe@xxxxxxxxxx>
  • Date: Wed, 26 Mar 2008 13:36:59 -0700
  • Message-id: <47EAB3EB.7090507@xxxxxxxxxx>
Randall R Schulz wrote:
On Wednesday 26 March 2008 12:07, Nick Zeljkovic wrote:
How can I delete these files w/o removing the folder itself?
find .thumbnails -type f -exec rm -rf {} \;

This could be very slow, since there must be a fork / exec for each file. Usually much faster is this:

% find dirName(s) {findCriteria} -print0 |xargs -0 rm

By doing this, xargs essentially "batches up" maximal (w.r.t. the argument size limit) sets of file names and invokes rm only as many times as necessary.

Note the use of find's -print0 option and the corresponding -0 option to xargs. This causes each file name to be delineated by a NUL character which means that files with spaces or other funky characters in their names won't mess things up.

That is excellent, world class advice. I will file that away.

As Dostoevsky said, It's always rewarding to talk to a clever man.


To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >