Skip to content

Instantly share code, notes, and snippets.

@triangletodd
Created March 21, 2012 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save triangletodd/2145867 to your computer and use it in GitHub Desktop.
Save triangletodd/2145867 to your computer and use it in GitHub Desktop.
Random quote from bash.org in a random Cowsay template
#!/bin/bash
bashorg=$(curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1)
files=($(cowsay -l|sed 's#Cow files in /usr/share/cowsay/cows:##'))
num_files=${#files[@]}
cowsay -f "${files[$((RANDOM%num_files))]}" ${bashorg}
unset bashorg files num_files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment