Random Data, Jot, and Sed

I spent a large part of today coding a script to spew meaningless text. Jill came home and I showed it to her. She of course asked me if it had any purpose? Not really, I said, but I sure learned a lot! Also, it looks really geeky in “code mode”. Yes, my script has three modes! One spits out nonsense words, one writes geeky-looking code, and the last spews random words from the dictionary.

The three lines of code that I spent hours on:


nice jot -r -n -c $line a z | rs -g | sed -e "s/..\{`jot -r 1 3 6`\}/ &/g" | sed -e "s/..\{`jot -r 1 3 6`\}/ &/g" | sed -e "s/[ ]\{2,\}/ /g" | tr -d "[:cntrl:]"


nice jot -r -s "" -c `jot -r 1 1 $line` | sed -e "s/.\{`jot -r 1 4 6`\}/ &/g" | sed -e "s/.\{`jot -r 1 4 6`\}/ &/g" | tr -d "[:cntrl:]" | sed -e "s/.\{`jot -r 1 1 $line`\}//g" | tr "[:upper:]" "[:lower:]"


n=`cat /usr/share/dict/words | wc -l`; cat /usr/share/dict/words | head -`jot -r 1 1 $n` | tail -1 | tr '\012' " "


As you can see, these make extensive use of the UNIX utilities jot, sed, and tr. I’ll be submitting this “hint” to macosxhints.com and hopefully it will be published!

If you have a better way to deal with the problem or can simplify my code, please feel free to leave a comment. Note that if you run these commands you will have to replace $line with a value such as 80 or 140 (which affects line length). The third one also depends on having a dictionary file with words only in the specified location.

Nate and Caroline came over tonight (19 days before their wedding!). When Caroline saw the code spewing forth, she asked in kind of an awed voice, “What is that?” I guess that’s one practical use of this code; it makes you look *really* geeky to non-geeks 🙂

  1. Yes I know, I’m psyched! I didn’t know you checked that site either, that’s a neat one.

  2. David H

    Hey Ben, this just got published on macosxhints.com!

Leave a Reply

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