jot and shuf

Software

Sounds like the name of a hipster microbrewary. Welcome to Jot and Shuff; we don't have a menu and our floors haven't been swept in a week, but we have terrible music. Enjoy!

There are dozens of ways to generate random numbers on *nix systems, for cryptograpic or other uses. Sometimes, you just want a simple integer between a certain range for use in a script.

The BSDs have long had the jot command, which can be employed for this task. For example, to return a random integer between 5 and 100:

% jot -r 1 5 100

The BSDs come with jot, because they're awesome. Linux users can install athena-jot.

Today though I also learned GNU shuf can be used for the same task on Linux and Solaris 11.

$ shuf -n 1 -i 5-100

For absolutely no reason whatsoever, have this string of numbers that shuf generated.

34 74 86 22 95 14 78 4

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!