Skip to content

Instantly share code, notes, and snippets.

@t3chn0m4g3
Last active August 22, 2016 15:07
Show Gist options
  • Save t3chn0m4g3/fdd15cbcf0eee4c1c0da6de971173cb4 to your computer and use it in GitHub Desktop.
Save t3chn0m4g3/fdd15cbcf0eee4c1c0da6de971173cb4 to your computer and use it in GitHub Desktop.
namegen
#!/bin/bash
fuRANDOMWORD () {
local myWORDFILE=/usr/share/dict/words
local myLINES=$(cat $myWORDFILE | wc -l)
local myRANDOM=$((RANDOM % $myLINES))
local myNUM=$((myRANDOM * myRANDOM % $myLINES + 1))
echo -n $(sed -n "$myNUM p" $myWORDFILE | tr -d \' | tr A-Z a-z)
}
myHOST=$(curl -s www.nsanamegenerator.com | html2text | tr A-Z a-z | awk '{print $1}')
if [ "$myHOST" = "" ]; then
echo "### Failed to fetch name from remote, using local cache."
myHOST=$(fuRANDOMWORD)$(fuRANDOMWORD)
fi
echo $myHOST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment