POV-Ray : Newsgroups : povray.off-topic : Adventures with digital painting : Re: Adventures with digital painting Server Time
12 Oct 2024 03:18:43 EDT (-0400)
  Re: Adventures with digital painting  
From: Darren New
Date: 8 Mar 2008 17:51:02
Message: <47d31856$1@news.povray.org>
Jim Henderson wrote:
> On Sat, 08 Mar 2008 11:54:07 -0800, Darren New wrote:
> 
>> Here's a contest. Given the directory /tmp/stuff, delete all the files
>> in that directory that end with ".tmp".
> 
> cd /tmp/stuff; find -type f | grep tmp$ | awk '{system("rm \"" $0 "\""))'

Great. Now try it on a directory with the following names in it:

-rf\n.tmp  (where the \n means newline, of course)
<.tmp
.xyz.tmp
hip"hop.tmp
hop'hip.tmp
this.tmp;that.tmp
this\bthat.tmp   (where the \b means bell)
this\bthat.tmp   (where the \b is two characters, backslash and b)

Two for zero... ;-)

Altho I expect 'find . -name '*.tmp' -exec rm {} \;" might work, but 
only because you know the name ends in '.tmp'.  You might be able to 
manage '-exec rm ./{}' and make it work too. I haven't tested that. I do 
know it'll be an order of magnitude slower due to all the invocations of 
/bin/rm.

For a real fun time, try "delete all the files in the directory without 
deleting the directory".  Or "copy them to the /tmp/keep" directory 
(which, as far as I can tell, xargs doesn't help with.)

(I work with big directories, and big files. Often I'll have a program 
that runs 3 hours, then takes half an hour to delete its input files. Or 
individual files that take 2 minutes of disk I/O to delete. Or empty 
directories that take several minutes to delete because they used to 
have six or seven million files in em.  And of course, the machine 
becomes completely unusable during any sort of operation like that.)

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.