Skip to content

Instantly share code, notes, and snippets.

@bkendzior
Created January 9, 2013 02:41
Show Gist options
  • Save bkendzior/4490101 to your computer and use it in GitHub Desktop.
Save bkendzior/4490101 to your computer and use it in GitHub Desktop.
Have a random cow tell you fortunes
# Have a random cow tell you fortunes
function cowsayfortune {
NUMOFCOWS=`cowsay -l | tail -n +2 | wc -w`
WHICHCOW=$((RANDOM%$NUMOFCOWS))
THISCOW=`cowsay -l | tail -n +2 | sed -e 's/\ /\'$'\n/g' | sed $WHICHCOW'q;d'`
#echo "Selected cow: ${THISCOW}, from ${WHICHCOW}"
fortune | cowsay -f $THISCOW -W 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment