Skip to content

Instantly share code, notes, and snippets.

@VSharapov
Forked from stevebest/randword.sh
Last active January 14, 2020 15:19
Show Gist options
  • Select an option

  • Save VSharapov/f4db3f2b8edc27bd8b9e3323e4869fcd to your computer and use it in GitHub Desktop.

Select an option

Save VSharapov/f4db3f2b8edc27bd8b9e3323e4869fcd to your computer and use it in GitHub Desktop.
Pick a random word from a dictionary
#! /usr/bin/env bash
WORDFILE="/usr/share/dict/words"
words=$(cat $WORDFILE | wc -l)
r=$(((RANDOM * 32768 + RANDOM)%$words+1))
sed -n "$r p" $WORDFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment