On Sun, Jul 17, 2011 at 3:54 PM, Pandu Poluan <pa...@poluan.info> wrote: > -original message- > Subject: Re: [gentoo-user] Any way around "Argument list too long"? > From: Alan Mackenzie <a...@muc.de> > Date: 2011-07-18 02:42 > >>Hi, Grant. >> >>On Sun, Jul 17, 2011 at 12:32:42PM -0700, Grant wrote: >>> My crontab deletes all files of a certain type in a certain folder >>> with yesterday's date in the filename. It usually executes but >>> sometimes fails with: >> >>> /bin/rm: Argument list too long >> >>> What would you do about this? >> >>Use xargs - in place of >> /bin/rm lots of files ...... >> >>Use >> Lots_of_file_names | xargs rm >> >>. xargs then calls rm several times with batches of filenames each time. >>xargs is a standard Unix command. > > You'll want to be extra careful with special characters like (space), single > quote, and double quote. > > Better use find ..... -exec rm {} + >
This is why I use 'find' with the -print0 parameter. find (path) (filespec) -print0|xargs -0 command -- :wq