Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Yukon Jack

macrumors member
Original poster
May 14, 2010
85
2
I'm looking for an app or script that will generate lists of random real (i.e. are in the English dictionary) words. Ideally I'd like to be able to control the word length but otherwise there's no other criteria.

I've checked the MAS and Macupdate as well as a general search of the Internet, but these turned up nothing but random text generators for creating passwords or gibberish filler text (such as lorem ipsum).

Of course there are plenty of Windoze apps but I don't have Parallels or Boot Camp so those are out.

thanks!

-Tod
 

dmi

macrumors regular
Dec 21, 2010
162
33
perl -ne 'rand($.)<1 and $word=$_;END{print $word}' /usr/share/dict/words

perl -MList::Util=shuffle -e 'print ((shuffle grep{length==8}<>)[0..9])' /usr/share/dict/words
 
Last edited:

Yukon Jack

macrumors member
Original poster
May 14, 2010
85
2
@ dmi: that's an unusual (but effective) solution. I'm familiar with Terminal but not with scripting. Is there a way to add to this script that will (a) select only words of a given length (say 5 characters) and (b) list more than one word at a time (say list 10 words)?

Thanks!

-Tod
 

dmi

macrumors regular
Dec 21, 2010
162
33
(a) select only words of a given length (say 5 characters) and (b) list more than one word at a time (say list 10 words)?
perl -MList::Util=shuffle -le 'print for (shuffle grep{chomp;length==5}<>)[0..9]' /usr/share/dict/words
 

Yukon Jack

macrumors member
Original poster
May 14, 2010
85
2
@ dmi: I didn't see your edit when I asked about word length and # of words.

Many thanks for creating this script. It is perfect for my use.

I don't see any functional difference between these two but they both work fine.

perl -MList::Util=shuffle -e 'print ((shuffle grep{length==6}<>)[0..9])' /usr/share/dict/words

perl -MList::Util=shuffle -le 'print for (shuffle grep{chomp;length==5}<>)[0..9]' /usr/share/dict/words

With best regards for a good weekend!

-Tod
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.