in reply to (jcwren) RE: Re: Deleting files over 2 weeks old?
in thread Deleting files over 2 weeks old?
And then I come along (as an ordinary user) and do the following:find /tmp /usr/tmp -atime +7 -print | xargs /bin/rm -f
And then sit back 7 days. Boom. You have no /etc/passwd.$ mkdir -p "/tmp/foo /etc" # yes, that's a newline after foo before the /etc $ touch "/tmp/foo /etc/passwd" # yes, that's a newline after foo again
The problem is that you are using newline as a delimiter, and yet it is a legal filename character. You need find .. -print0 and xargs with a -0, but that's not portable. Even though Perl isn't strictly everywhere, it's everywhere the perlmonks are, so my solution succeeds in a safe way.
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: (jcwren) RE: Re: Deleting files over 2 weeks old?
by Jonathan (Curate) on Aug 03, 2000 at 13:15 UTC | |
|
RE: RE: (jcwren) RE: Re: Deleting files over 2 weeks old?
by jettero (Monsignor) on Aug 03, 2000 at 04:46 UTC | |
by merlyn (Sage) on Aug 03, 2000 at 04:50 UTC |