No seq on Mac OS X - use jot insteadNo seq on Mac OS X - use jot instead

Posted November 25th, 2010 in OSX

I'm used to using the seq command line tool on Linux for generating a sequence of numbers (which is useful if you need to download a bunch of files with wget which have consecutive numbering in the filename). I went to use it on OSX but there's no seq. A quick Google and I learned there's "jot" instead.

jot

jot has a few more capabilities than seq, but at its simplest to make it the same as the seq command to print the numbers 1 to 10, which would be:

seq 1 10

do this instead with jot:

jot - 1 10

Note the spaced hyphen between the command and the first number; without this it will only print the number 10.

Downloading sequentially numbered files with jot

As a little bonus for this post, and the whole reason I wrote it in the first place, was because I needed to download some files which were sequentially numbered from 1 to 100. Using a combination of wget and jot you could do this, where the files are images named image1.gif to image100.gif:

for number in `jot - 1 100`; do wget http://domain/images/image$number.gif; done

Easy, huh?

Related posts:

Comments

blog comments powered by Disqus