Don't like ads? PRO users don't see any ads ;-)
Guest

Greet

By: a guest on May 8th, 2012  |  syntax: Bash  |  size: 0.37 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. COW_PATH=/usr/share/cows
  3.  
  4. files=($COW_PATH/*.cow)     # Ought to figure this array thing out.
  5. N=${#files[@]}
  6. ((N=RANDOM%N))
  7. cow=${files[$N]}
  8.  
  9.  
  10. h=`date +%H`
  11. case $h in
  12.     0[0-9]|1[0-1]) greeting="Good morning!"
  13.     ;;
  14.      1[2-9]) greeting="Good afternoon!"
  15.     ;;
  16.     2[0-4]) greeting="Good evening!"
  17.     ;;
  18. esac
  19.  
  20. cowsay -f $cow $greeting
  21.  
  22. exit 0