Last active
November 6, 2021 18:59
-
-
Save pystardust/e7abf60b1580a144f9516bd33290c88c to your computer and use it in GitHub Desktop.
random domain names
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 | |
# Generating random domain names | |
temp_file=`mktemp` | |
get_word() { | |
word=$( | |
xidel -s https://www.thisworddoesnotexist.com/ --css "#definition-word" | |
) | |
if (( ${#word} < 8 )); then | |
word=$(sed 's/[^a-z A-Z]//g;s/$/.com/' <<< "$word") | |
flock "$temp_file" printf '%s\n' "$word" >> "$temp_file" | |
fi | |
printf '.' | |
} | |
export temp_file | |
export -f get_word | |
for (( i=0 ; i<100 ; i++)); do | |
sem -j 20 "get_word" | |
done | |
sem --wait | |
printf '\n' | |
readarray -t domains < "$temp_file" | |
rm "$temp_file" | |
printf '%s\n' "${domains[@]}" | |
printf 'found %d names\n' "${#domains[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment