Create an array with a sequence of numbers in bash

Using seq you can say seq FIRST STEP LAST. In your case:

seq 0 0.1 2.5

Then it is a matter of storing these values in an array:

vals=($(seq 0 0.1 2.5))

You can then check the values with:

$ printf "%s\n" "${vals[@]}"
0,0
0,1
0,2
...
2,3
2,4
2,5

Yes, my locale is set to have commas instead of dots for decimals. This can be changed setting LC_NUMERIC="en_US.UTF-8".

By the way, brace expansion also allows to set an increment. The problem is that it has to be an integer:

$ echo {0..15..3}
0 3 6 9 12 15

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)