#!/usr/bin/env bash WORDFILE="/usr/share/dict/words" NUMWORDS=${1:-5} #Number of lines in $WORDFILE tL=`awk 'NF!=0 {++c} END {print c}' $WORDFILE` for i in `seq $NUMWORDS` do rnum=$(($RANDOM*$RANDOM)) let "rnum %= $tL" sed -n "$rnum p" $WORDFILE done