POV-Ray : Newsgroups : povray.off-topic : Adventures with digital painting Server Time
14 Nov 2024 22:22:24 EST (-0500)
  Adventures with digital painting (Message 71 to 80 of 197)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Jim Henderson
Subject: Re: Adventures with digital painting
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

From: Jim Henderson
Subject: Re: Adventures with digital painting
Date: 8 Mar 2008 21:10:17
Message: <47d34709$1@news.povray.org>
On Sat, 08 Mar 2008 17:44:45 -0500, Warp wrote:

> Jim Henderson <nos### [at] nospamcom> wrote:
>> cd /tmp/stuff; find -type f | grep tmp$ | awk '{system("rm \"" $0
>> "\""))'
> 
>   Why does it need to be so complicated?
> 
>   find /tmp/stuff -name "*.tmp" -exec rm {} \;

Because there's a million ways to do it, and I haven't memorised all the 
options for the find command.

In the time that it would take me to look up the options for find, I've 
written the command-line out.

Jim


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Adventures with digital painting
Date: 8 Mar 2008 21:12:09
Message: <47d34779$1@news.povray.org>
Jim Henderson escribió:
> 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. :-)

Can filenames have null characters on them? :)


Post a reply to this message

From: Chambers
Subject: Re: Adventures with digital painting
Date: 8 Mar 2008 22:04:09
Message: <47d353a9$1@news.povray.org>
Orchid XP v7 wrote:
> Chambers wrote:
> 
>> So what you're really saying, is that we need a modern implementation 
>> of traditional Unix style tools, distributed as a package.  It 
>> wouldn't need a ton of that backwards-compatibility stuff, because all 
>> of the included tools are fresh implementations that we know work 
>> together.
> 
> What I'm saying is that "Unix" isn't a single coherant design. It's 
> 50,000 random people all doing their own seperate thing, and expecting 
> the result to actually function. Which, almost unbelievably, it does. 
> But *damn* is it messy...

When you're writing a single, simple tool, with well defined inputs and 
outputs, it's much easier to make it work *no matter what*.  When each 
tool is maintained by a separate group of people, they may not share the 
same design ideology, but they're much more likely to operate correctly 
under unexpected circumstances.

So the fact that it works as often as it does shouldn't really surprise 
anyone.

-- 
...Ben Chambers
www.pacificwebguy.com


Post a reply to this message

From: Jim Henderson
Subject: Re: Adventures with digital painting
Date: 8 Mar 2008 23:06:56
Message: <47d36260$1@news.povray.org>
On Sun, 09 Mar 2008 00:11:49 -0200, Nicolas Alvarez wrote:

> Jim Henderson escribió:
>> 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. :-)
> 
> Can filenames have null characters on them? :)

A null character can be represented as a value, so yes.

Jim


Post a reply to this message

From: Eero Ahonen
Subject: Re: Adventures with digital painting
Date: 9 Mar 2008 03:17:01
Message: <47d39cfd$1@news.povray.org>
Darren New wrote:
> 
> % cat a b c >d
> Can't create d: permission denied
> % sudo !!
> Can't create d: permission denied
> 
> Of course, the real line was much longer, so a simple "su" meant 
> retyping the line (or using copy-and-paste to retype it for you) instead 
> of just !! or up-arrow. :-)
> 

<up arrow><home>su -c <enter>

-- 
Eero "Aero" Ahonen
    http://www.zbxt.net
       aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: Warp
Subject: Re: Adventures with digital painting
Date: 9 Mar 2008 04:55:23
Message: <47d3b40b@news.povray.org>
Jim Henderson <nos### [at] nospamcom> wrote:
> On Sat, 08 Mar 2008 17:44:45 -0500, Warp wrote:

> > Jim Henderson <nos### [at] nospamcom> wrote:
> >> cd /tmp/stuff; find -type f | grep tmp$ | awk '{system("rm \"" $0
> >> "\""))'
> > 
> >   Why does it need to be so complicated?
> > 
> >   find /tmp/stuff -name "*.tmp" -exec rm {} \;

> Because there's a million ways to do it, and I haven't memorised all the 
> options for the find command.

> In the time that it would take me to look up the options for find, I've 
> written the command-line out.

  But now you know. The -exec option of find is actually quite useful.
Learn to use your tools. :)

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Adventures with digital painting
Date: 9 Mar 2008 11:37:27
Message: <47d41247$1@news.povray.org>

> Darren New wrote:
>>
>> % cat a b c >d
>> Can't create d: permission denied
>> % sudo !!
>> Can't create d: permission denied
>>
>> Of course, the real line was much longer, so a simple "su" meant 
>> retyping the line (or using copy-and-paste to retype it for you) 
>> instead of just !! or up-arrow. :-)
>>
> 
> <up arrow><home>su -c <enter>

On some ssh sessions, and on MSYS bash shell, pressing home or end keys 
types a ~ symbol instead of moving the cursor. Probably something I have 
to configure...


Post a reply to this message

From: Jim Henderson
Subject: Re: Adventures with digital painting
Date: 9 Mar 2008 15:25:27
Message: <47d447b7@news.povray.org>
On Sun, 09 Mar 2008 04:55:23 -0500, Warp wrote:

> Jim Henderson <nos### [at] nospamcom> wrote:
>> On Sat, 08 Mar 2008 17:44:45 -0500, Warp wrote:
> 
>> > Jim Henderson <nos### [at] nospamcom> wrote:
>> >> cd /tmp/stuff; find -type f | grep tmp$ | awk '{system("rm \"" $0
>> >> "\""))'
>> > 
>> >   Why does it need to be so complicated?
>> > 
>> >   find /tmp/stuff -name "*.tmp" -exec rm {} \;
> 
>> Because there's a million ways to do it, and I haven't memorised all
>> the options for the find command.
> 
>> In the time that it would take me to look up the options for find, I've
>> written the command-line out.
> 
>   But now you know. The -exec option of find is actually quite useful.
> Learn to use your tools. :)

Yes, now I know - and I never would claim to "know it all" (been burned 
too many times with things I do know more than the average person about - 
and then had something pointed out I didn't know <g>).

So I do appreciate you teaching me that one.  New weapon for the 
arsenal. :-)

Jim


Post a reply to this message

From: Warp
Subject: Re: Adventures with digital painting
Date: 10 Mar 2008 04:20:23
Message: <47d4fd56@news.povray.org>
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> > <up arrow><home>su -c <enter>

> On some ssh sessions, and on MSYS bash shell, pressing home or end keys 
> types a ~ symbol instead of moving the cursor. Probably something I have 
> to configure...

  ctlr-a to get to the beginning of the line, ctrl-e to get to the end.
(ctrl-u to erase the entire line is a good shortcut to know too. ctrl-l
clears the console (in interactive full-console programs it usually
refreshes the console).)

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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