Created
August 1, 2026 04:21
-
-
Save alexwilson/9069b5ca23ae6d7e7dd36d3bf291872e to your computer and use it in GitHub Desktop.
genhostname.sh
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
| genhostname() { | |
| local words=${1:-4} | |
| local dict=${DICT:-/usr/share/dict/words} | |
| local result="" | |
| for i in $(seq 1 "$words"); do | |
| lines=$(wc -l < "$dict") | |
| rand=$(openssl rand 4 | od -An -tu4 | tr -d ' ') | |
| index=$(( rand % lines + 1 )) | |
| word=$(sed -n "${index}p" "$dict" | tr 'A-Z' 'a-z' | tr -cd 'a-z') | |
| result="${result}${word}-" | |
| done | |
| num=$(openssl rand 2 | od -An -tu2 | tr -d ' ') | |
| echo "${result}${num}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment