Gentoo Archives: gentoo-user

From: Michael Mol <mikemol@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Any way around "Argument list too long"?
Date: Sun, 17 Jul 2011 21:52:53
Message-Id: CA+czFiCmK8Be26q9HOig+tO5g-Pzhz7MZ72wNgDG-regjNsB_g@mail.gmail.com
In Reply to: RE: [gentoo-user] Any way around "Argument list too long"? by Pandu Poluan
1 On Sun, Jul 17, 2011 at 3:54 PM, Pandu Poluan <pandu@××××××.info> wrote:
2 > -original message-
3 > Subject: Re: [gentoo-user] Any way around "Argument list too long"?
4 > From: Alan Mackenzie <acm@×××.de>
5 > Date: 2011-07-18 02:42
6 >
7 >>Hi, Grant.
8 >>
9 >>On Sun, Jul 17, 2011 at 12:32:42PM -0700, Grant wrote:
10 >>> My crontab deletes all files of a certain type in a certain folder
11 >>> with yesterday's date in the filename.  It usually executes but
12 >>> sometimes fails with:
13 >>
14 >>> /bin/rm: Argument list too long
15 >>
16 >>> What would you do about this?
17 >>
18 >>Use xargs - in place of
19 >>    /bin/rm lots of files ......
20 >>
21 >>Use
22 >>   Lots_of_file_names | xargs rm
23 >>
24 >>.  xargs then calls rm several times with batches of filenames each time.
25 >>xargs is a standard Unix command.
26 >
27 > You'll want to be extra careful with special characters like (space), single quote, and double quote.
28 >
29 > Better use find ..... -exec rm {} +
30 >
31
32 This is why I use 'find' with the -print0 parameter.
33
34 find (path) (filespec) -print0|xargs -0 command
35
36 --
37 :wq