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