rolldice 237 B

123456789101112131415
  1. #!/bin/bash
  2. # GPLv3 or later. see COPYING.GPL
  3. if [[ -z $1 ]]; then
  4. echo "usage: 1dN"
  5. exit;
  6. fi
  7. rand=$(od -N 4 -t uL -An /dev/urandom | tr -d " ")
  8. let MOD=`echo $1 | sed -e 's/1d//'`
  9. # echo "MOD:" $MOD
  10. let OUT=($rand%$MOD)+1
  11. echo $OUT