Advertisement
metalx1000

Rolling Dice in BASH

Jan 18th, 2015
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4.  
  5. dice=('\xe2\x9a\x80' '\xe2\x9a\x81' '\xe2\x9a\x82' '\xe2\x9a\x83' '\xe2\x9a\x84' '\xe2\x9a\x85')
  6.  
  7. if [ "$1" = "" ]
  8. then
  9.   num=2
  10. else
  11.   num=$1
  12. fi
  13.  
  14. echo "Rolling $num dice..."
  15. sides=${#dice[@]}
  16.  
  17. for i in `seq 1 $num`
  18. do
  19.   r=$(($RANDOM%$sides))
  20.   echo -en ${dice[$r]}
  21.   sleep .1
  22. done
  23.  
  24. #new line
  25. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement