{"id":425,"date":"2008-05-23T22:57:29","date_gmt":"2008-05-24T03:57:29","guid":{"rendered":"http:\/\/theholtsite.com\/blog\/2008\/05\/23\/425\/"},"modified":"2008-05-23T23:02:19","modified_gmt":"2008-05-24T04:02:19","slug":"425","status":"publish","type":"post","link":"https:\/\/theholtsite.com\/blog\/425\/","title":{"rendered":"Random Data, Jot, and Sed"},"content":{"rendered":"<p>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 &#8220;code mode&#8221;.  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.<\/p>\n<p>The three lines of code that I spent hours on:<\/p>\n<p><code><br \/>\nnice 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:]\"<br \/>\n<\/code><br \/>\n<code><br \/>\nnice 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:]\"<br \/>\n<\/code><br \/>\n<code><br \/>\nn=`cat \/usr\/share\/dict\/words | wc -l`; cat \/usr\/share\/dict\/words | head -`jot -r 1 1 $n` | tail -1 | tr '\\012' \" \"<br \/>\n<\/code><br \/>\n<code><\/code><br \/>\nAs you can see, these make extensive use of the UNIX utilities jot, sed, and tr.  I&#8217;ll be submitting this &#8220;hint&#8221; to <a href=\"http:\/\/macosxhints.com\">macosxhints.com<\/a> and hopefully it will be published!<\/p>\n<p>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.<\/p>\n<p>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, &#8220;What is that?&#8221;  I guess that&#8217;s one practical use of this code; it makes you look *really* geeky to non-geeks \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;code mode&#8221;. Yes, my script has [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-425","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/posts\/425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/comments?post=425"}],"version-history":[{"count":0,"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/posts\/425\/revisions"}],"wp:attachment":[{"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/media?parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/categories?post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theholtsite.com\/blog\/wp-json\/wp\/v2\/tags?post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}