[clug] Shell glob for a range of numbers? (We have a winner)
Nathan Rickerby
nath at yossman.net
Fri Jan 9 04:15:21 GMT 2004
Well done. For some reason I was reading the cp and thinking mv. In
which case, on repeats the [ would fail and $target wouldn't
decrement.
On Fri, Jan 09, 2004 at 03:06:11PM +1100, Michael Still wrote:
> On Fri, 9 Jan 2004, Mark Triggs wrote:
>
> > Michael Still <mikal at stillhq.com> writes:
> >
> > > On Fri, 9 Jan 2004, James Ring wrote:
> > >
> > > [Ditto on the wierd non-cc thing]
> > >
> > >> The loop should always decrement the counter, not only when the given
> > >> file exists. This code will loop infinitely if any file argus.log.X.gz
> > >> does not exist.
> > >>
> > >> I think...
> > >
> > > No, the decrement is in the right place, but you're the closest yet.
> >
> > There's nothing to ensure that it copies a different file each time
> > around the loop, so there's no guarantee it will actually end up
> > copying all of the files within the number range.
>
> Yes! There is no test in the code to see if we've copied this log file
> before. We could end up with 22 copies of one log file, if it wasn't for
> the fact that they'd all overwrite each other (and thus we'd only see one
> file in /tmp).
>
> Is that clear to everyone?
>
> I'm thinking I'll bring a treat to CLUG the honourable mentions as well...
>
> Cheers,
> Mikal
>
> PS: I was assured in a private mail that my script approximated an answer
> for a Bell labs programming competition entitled "write the worst possible
> sort".
>
> --
>
> Michael Still (mikal at stillhq.com) | "All my life I've had one dream,
> http://www.stillhq.com | to achieve my many goals"
> UTC + 11 | -- Homer Simpson
More information about the linux
mailing list