on
Non solum seq sed etiam jot
On Linux there is this useful tool seq. It is used to generate sequences of numbers. Calling it like seq 1 10 results in 1, 2, 3, …, 10 being printed. This is great if you need to run a loop in your shell scripts, e.g. for i in seq 1 255; do ping -c 192.168.1.$i; done
On MacOS X there is no seq. While searching for the source of seq to compile it on my own, I found an article about the very same problem. This article shows three solutions:
-
A simple shell script that (nearly) does what
seqdoes. -
jot, a BSD tool that produces sequences:for i injot 10 1; do …(produce 10 numbers starting at 1) -
{<from>..<to>}. The bash shell has a syntax to produce sequences:for i in {1..10}; do …
All three solutions have different syntax. The shell script is available on machines you copy it to but nowhere else. So forget this. seq is on all Linux machines I have seen so far, most Solaris machines but not on MacOS X. So no option for me. jot seems to be very powerful (you need 17 numbers between -2.3 and +4.2? jot 17 -2.3 4.2) but it is BSD only, usually not found on Linux or Solaris. So, my new favourite is the bash syntax. I’m using bash anyways and it has all the power i need: arbitrary start and end, counting upwards and downwards.