Cowsay is a fun little app that draws a cow that says things, but you can do so much more than a cow, there’s all sorts of fun ascii art critters in there; but how do we get to them? Lots of solutions simply find the directory where cowfiles (the templates that define the critters) are stored and hard-code that; but how do you know where they are?
Turns out, cowsay will tell you if you pass the
-l flag like so:
which outputs the directory, and a list of all available cowfiles - much simpler
find. But if there’s a list of cowfiles there, why bother using
ls to get the directory listing? simply trim off the first line by piping to
sed, and ask it to delete it
now we’ve got a nice clean list to randomize; You could use
shuf, or bash’s
built-in array-mangling utilities; for sake of portability, this script uses
store that as a script (i.e.
cowsay.sh), put it in your path, and soon you
will find randomized cow bliss. check it out
$RANDOM bit looks familiar, where have I seen that before? oh yeah -
it’s the only functional part in “my” Oblique Strategies script.