POV-Ray : Newsgroups : povray.off-topic : Adventures with digital painting : Re: Adventures with digital painting Server Time
12 Oct 2024 01:13:04 EDT (-0400)
  Re: Adventures with digital painting  
From: Jim Henderson
Date: 8 Mar 2008 21:09:36
Message: <47d346e0$1@news.povray.org>
On Sat, 08 Mar 2008 14:51:02 -0800, Darren New wrote:

> 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... ;-)

I *think* if I were to do a single quote rather than a double, that would 
solve most of those problems.  Maybe not the one with the single tick in 
it, but a gsub for a pattern of special characters would do it.

But of course, I try not to name files with special characters - not 
always successfully (occasionally torrents that I pull down have names 
that are stupidly in violation of all standards for file naming).

But if I wanted it to work all the time, I'd write it in C and be done 
with it - then the shell doesn't come into play. :-)

> (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.)

I occasionally do things like this myself - that's the reason I didn't 
try to pass all the files on the command-line to a single rm command.  
BTDTGTTS. :-)

Jim


Post a reply to this message

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