Sea of Noise

Sun, 16 Jul 2006

Generating Random Data With jot

Today's entry in the "do one thing and do it well" sweepstakes is a nifty little utility I found just lying around on my FreeBSD system with an apropos random. I need some psuedorandom data to stick in large file and I figured I ought to be able to get it from the shell. Sure enough, jot was just what I wanted!

Need to think of a number between 1 and 10?

jot -r 1 1 10

Need an 80-character line of random printable characters?

jot -r -s "" -c 80 ! ~

You can do the same thing using ASCII codes to reference the range of characters:

jot -r -s "" -c 80 33 126

I suspect you can see how the above would be nice for testing scripts or generating Lorem Ipsum style filler. Of course, you can use a wider range of characters if you're not going to look at them on-screen, and that's very nice for filling up a file:

jot -r -s "" -c 1024 0 255 > foo

Voila! A nice, not-very-compressable 1k file!

Don't delay! Try a man jot at a shell prompt near you today!

[/it] permanent link

Syndicate Me via RSS!

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.

Powered by Blosxom!