 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Nicolas Alvarez wrote:
> >> Here's a contest. Given the directory /tmp/stuff, delete all the files
> >> in that directory that end with ".tmp".
> >>
> >> Let's see how many iterations it takes to get actually right.
> >
> > Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
> That doesn't even work if there *aren't* funky characters in the file name.
It *does* work, assuming you have a sufficiently modern shell (and not
a 20 years old sh). Modern shells are rather smart at escaping what needs
to be escaped when you write "*".
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Nicolas Alvarez wrote:
>>>> Here's a contest. Given the directory /tmp/stuff, delete all the files
>>>> in that directory that end with ".tmp".
>>>>
>>>> Let's see how many iterations it takes to get actually right.
>>> Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
>
>> That doesn't even work if there *aren't* funky characters in the file name.
>
> It *does* work, assuming you have a sufficiently modern shell (and not
> a 20 years old sh). Modern shells are rather smart at escaping what needs
> to be escaped when you write "*".
Bull. Put 300,000 files to be deleted in /tmp/stuff, and watch it bomb.
--
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v7 wrote:
>> I love the Unix philosophy of making specific, lightweight tools that
>> interoperate, rather than gargantuan monolithic beasts that do
>> everything rather poorly.
>
> See, now, personally I hate that. It annoys the hell out of me that the
> Unix way is to use 50,000 tiny tools with all have far too many
> backwards compatibility modes, bugs and "features".
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.
--
...Ben Chambers
www.pacificwebguy.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v7 <voi### [at] dev null> wrote:
> 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...
I really fail to see how that is at all different from Windows. ;)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Sat, 08 Mar 2008 10:46:57 -0800, Chambers wrote:
> Nicolas Alvarez wrote:
>> Tim Cook escribió:
>>> Heck, I use version 7...even 8 was too bloatware for my taste.
>>
>> http://stuff.povaddict.com.ar/psp5.png
>>
>> I tried 8 or 9 and I was impressed at the amount of bloat.
>
> I love the Unix philosophy of making specific, lightweight tools that
> interoperate, rather than gargantuan monolithic beasts that do
> everything rather poorly.
Ditto. When I do data manipulation now in oocalc, I often parse the data
first by piping it through a series of awk scripts and grep filters to
get the data I'm interested in, *then* import it.
Makes it easier to aggregate the stuff I look at.
Jim
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Sat, 08 Mar 2008 19:16:28 +0000, Orchid XP v7 wrote:
> ["This makes it read from a file. Unless the file is named '-', in which
> case it reads from stdin." OK, so how do I make it read from a file
> that's actually named '-' then? And other surprising ad-hoc
> behaviours...]
(a) you don't name a file '-' because it's got a special meaning to the
shell, or
(b) you escape the filename.
Jim
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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 "\""))'
Jim
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Jim Henderson <nos### [at] nospam com> 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 {} \;
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |