2

Suppose I have these two numbers: 800000 and 3200000. I want to find five numbers with an even difference in between these two numbers. Therefore, I want the output to be:

800000
1200000
1600000
2000000
2400000
2800000
3200000

I know about the seq command but I'm not sure how to do this.

Amarakon
  • 289
  • 3
  • 9

2 Answers2

4

Using jot:

$ jot 7 800000 3200000
800000
1200000
1600000
2000000
2400000
2800000
3200000

The jot utility is available by default on most BSD systems but may also be installed on, e.g., Debian GNU/Linux and Ubuntu Linux. The apt package containing jot seems to be called athena-jot.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
0

Using any awk in any shell on every Unix box:

$ awk -v b=800000 -v e=3200000 -v n=5 'BEGIN{d=int((e-b)/(n+1)); for (i=b; i<e; i+=d) print i; print e}'
800000
1200000
1600000
2000000
2400000
2800000
3200000
Ed Morton
  • 28,789
  • 5
  • 20
  • 47