bin-utils/rword.sh

15 lines
257 B
Bash
Raw Normal View History

2015-05-30 16:42:42 +00:00
#!/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