bin-utils/rword.sh
2015-05-30 18:42:42 +02:00

15 lines
257 B
Bash
Executable File

#!/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