[clug] Shell glob for a range of numbers?
Carter, Michael
Michael.Carter at dsto.defence.gov.au
Fri Jan 9 04:06:21 GMT 2004
hmmm... my guess would be that this would copy sixteen random files in the range
5-21, but not necessarily each one once. You'd probably miss at least one and get one at least twice.
mick
> > [untested code follows]
> >
> > target=$(( 21 - 5 ))
> > while [ $target != 0 ]
> > do
> > averybadnameforavariable=$RANDOM
> > if [ $averybadnameforavariable -lt 22 ]
> > then
> > if [ $averybadnameforavariable -lt 4 ]
> > then
> > if [ -f argus.log.$averybadnameforavariable.gz ]
> > then
> > cp argus.log.$averybadnameforavariable.gz /tmp
> > target=$(( $target - 1 ))
> > fi
> > fi
> > fi
> > done
> >
> > Now, I'll leave putting that on one line for an exercise
> for the reader.
>
> Oh, and quiz for the reader. What is the critical bug in this code?
>
> Mikal
More information about the linux
mailing list