Last active
August 22, 2016 15:07
-
-
Save t3chn0m4g3/fdd15cbcf0eee4c1c0da6de971173cb4 to your computer and use it in GitHub Desktop.
namegen
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 | |
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