(Potentially) funny random filenames for Bash scripts
It’s been a busy week, and I’ll be writing up my WWDC thoughts and a couple of TUAW posts after a plane ride today. In the meantime, I made you a thing.
This quick function is part of a script I wrote to generate multiple files filled with random Markdown lipsum with an index for Marked testing.
Numbered files are boring, and truly random character sequences aren’t much fun. Aspell has a master dictionary that happens to contain a lot of potentially funny words. I decided to dump those and randomly pick two to string together as filenames.
The function uses a dictionary file (single word per line) and shuf
, available through Homebrew in the Gnu coreutils
package (brew install coreutils
). You can create a dictionary file using Aspell (brew install aspell
) with the command aspell dump master > dictionary.txt
(or just grab the one I made). Be sure to edit the “wordfile” variable in the function to point to the location of your dictionary.
For the try-before-you-buy fans, here are sample results using the Aspell dictionary:
$ while true; do gen_random_filename; done
worldviews_punctualitys
eddys_dodge
Beaujolais_unjustifiably
doxology_teatimes
peignoirs_toilet
paling_landlords
OToole_Superglue
verrucae_resented
casseroling_rumble
Tharps_interbred
misjudgment_strum
workhouse_frisson
solstices_fifes
isotherms_interlocks
riotously_Scud
knockabout_skinflints
volcano_resewn
nubs_imprudences
geezers_disturbing
^C
Ryan Irelan has produced a series of shell trick videos based on BrettTerpstra.com posts. Readers can get 10% off using the coupon code TERPSTRA
.