Most every Linux system comes with GNU seq (a utility to generate sequences of numbers or characters). However, a much older utility – and more flexible one – is the underutilized and unknown utility, jot. Every BSD system, including MacOS X, will come with jot (and not with seq).
Unfortunately, commercial UNIX tends to come with neither. So unless you are using an open source operating system, both of these utilities are unavailable. This is unfortunate.
To install jot under Debian Linux and variants (including Ubuntu), install the athena-jot package. FreeBSD, OpenBSD, and MacOS X should already have jot installed out of the box.
Using jot is easy:
- Generate a count 1 to 6:
jot 6
- Generate a count 5 to 10:
jot 6 5
- Print “y” 100 times:
jot -b y 100
- Generate a count 1 to 6 separated by commas:
jot -s "," 6
- Generate abc1 to abc20:
jot -w abc 20
This only begins to touch on the capabilities of jot. It can also generate random numbers and random character data.
In fact, to generate a large file (5Gb in this case), try this:
jot -r -c -s '' $(( 1024 * 1024 * 5 )) > file.5gb
If you do install the athena-jot package on Ubuntu or Debian, you may want to do this:
cd /usr/share/man/man1
sudo ln -s athena-jot.1.gz jot.1.gz
For some reason, the package – and the manpage – are called athena-jot but the utility is actually jot (not athena-jot). The FreeBSD man page for jot(1) (PDF)has more details.