[clug] Shell glob for a range of numbers? (We have a winner)

Michael Still mikal at stillhq.com
Fri Jan 9 04:06:11 GMT 2004

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


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


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