Created
November 25, 2019 15:02
-
-
Save isaaclw/bac16bfebb6769317978b5068de17025 to your computer and use it in GitHub Desktop.
List 10 random words #bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WORDFILE="/usr/share/dict/words" | |
NUMWORDS=10 | |
#Number of lines in $WORDFILE | |
tL=`awk 'NF!=0 {++c} END {print c}' $WORDFILE` | |
for i in `seq $NUMWORDS`; do | |
rnum=$((RANDOM%$tL+1)); | |
sed -n "$rnum p" $WORDFILE; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment