Re: [ILUG] shell script question

From: Niall (niall at domain inpho.ie)
Date: Wed 03 May 2000 - 13:24:03 IST


> yeah, forgot about seq.. doh, and that does the job perfectly on linux.
> (which makes me happy for now).
>
> but how about a native sh or bash way for other Unices?

Well, you could do something like

limit=256
for hundreds in 0 1 2
do for tens in 0 1 2 3 4 5 6 7 8 9
   do for units in 0 1 2 3 4 5 6 7 8 9
      do number=${hundreds}${tens}${units}
         if [ $number -lt $limit ] ; then
            echo $number
         fi
      done
   done
done

which I've actually done before, to my shame (in that I'm sure there must
be a better way, even with sh, but I had a problem to solve).

Regards,

Niall O Broin



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:00 GMT