jot it up

While reading through UNIX powertools tonight, I came across jot. This nifty little utility will print a sequence of numbers, which can be used to iterate through a loop:

$

for i in `jot 5`
do
    echo $i
done

1
2
3
4
5

Using jot in this way is typically faster than other mechanisms (e.g., i=`expr $i+1`), and is easier to read IMHO. Jot it up yizos!

3 thoughts on “jot it up”

  1. Yup its basically a more up-to-date seq. Both useful. Consider that you can also generate sequences of numbers in bash3:
    for i in {1..10}; do echo $i; done
    But bash3 only, not previous versions.

    Interestingly jot seems to be linux/bsd only. I’ve ported the bsd version to solaris. I’ll make it available if anyone wants it.

Leave a Reply

Your email address will not be published. Required fields are marked *