Re: Petal temp files

Fergal Daly <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
On Tue, Feb 15, 2005 at 09:50:03PM +0100, Olaf Buwen wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> find /tmp -name 'petal_*' -mtime +30 | xargs rm
> 
> should find and delete all petal files in /tmp older than 30 days.
> 
> but fear filenames like 'petal_fake;rm -rf ..;#ignore'
> if you feed the list to a shell script!

If you do

find /tmp  -name 'petal_*' -mtime +30 -print0 | xargs -0 rm

then the -print0 for find will make it output \0 (ie the NULL character) as
the file separator instead of \n. -0 for xargs tells it to expect the files
to be separated by \0 instead of \n. This guarantees no funny with ;s or
spaces business because filenames cannot contain \0,

Fergal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.