Skip to content

Instantly share code, notes, and snippets.

@isaaclw
Created November 25, 2019 15:02
Show Gist options
  • Save isaaclw/bac16bfebb6769317978b5068de17025 to your computer and use it in GitHub Desktop.
Save isaaclw/bac16bfebb6769317978b5068de17025 to your computer and use it in GitHub Desktop.
List 10 random words #bash
#!/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