guenstigwerben

Fortune / Cowsay

Aug 5th, 2015
2,776
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # This script gets a random available cow with `cowsay -l` and prints some text, default fortune
  4.  
  5. FORTUNE="fortune"
  6.  
  7. for COWNAME in `cowsay -l | tail -n +2`
  8. do
  9. COWS+=$COWNAME
  10. COWS+='\n'
  11. done
  12. COWS=${COWS%??}
  13. RANDOMCOW=$(echo -e $COWS | sort -R | head -n 1)
  14. $FORTUNE | cowsay -f $RANDOMCOW
RAW Paste Data