[YLUG][OT] alternatives to seq when scripting for loops

john halewood john.halewood at gmail.com
Fri Nov 17 16:48:35 GMT 2006


On 17/11/06, Rachel Cavill <rachel.cavill at googlemail.com> wrote:
> I've tried an equivalent bash solution using a while loop and
> incrementing instead of a forloop - but I'm having problems with the
> fact that I don't want to use integers.  The loop works fine if I set
> everything to integer values, but the minute I try to use real values
> I'm getting error messages.
>
> I know I'm missing something obvious here, but what is it?
> Rachel

It's a hack basically - bash uses long ints for variables; but using
the printf statement you can do something like:
for (( i=0; i<10; i++)); do echo 1.$(printf "%01d" $i); done
which will print out the sequence 1.0 - 1.9.

Alternatively, it might in the long run be easier to download and
compile the gnu coreutils package, install it in your home directory
and put it in your path.

cheers
john



More information about the York mailing list