Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created March 7, 2018 19:25
Show Gist options
  • Save jhyland87/90b49cbeb64a1915bd43ab66658e00d3 to your computer and use it in GitHub Desktop.
Save jhyland87/90b49cbeb64a1915bd43ab66658e00d3 to your computer and use it in GitHub Desktop.
Geoffs failure
#!/usr/local/bin/bash
function center {
if test -p /dev/stdin; then
data=$(</dev/stdin)
elif test -a ${1}; then
data=$(cat ${1})
elif test -n ${1}; then
data=$*
else
_err "No content provided"
return 1
fi
total="10"
colpad="$(seq -f "=" -s '' ${total})"
texttotal="30"
textsize="$(((${texttotal}-${#1})/2))"
textpad="$(seq -f " " -s '' ${textsize})"
printf '%s%s%s%s%s\n' "${colpad}" "${textpad}" "${data}" "${textpad}" "${colpad}"
}
wordlist="/usr/share/dict/words"
tL=`awk 'NF!=0 {++c} END {print c}' ${wordlist}`
for i in $(seq 10); do
rnum=$((RANDOM%$tL+1))
sed -n "${rnum} p" ${wordlist} | center
done
# Results
# ========== Apachette ==========
# ========== bricklining ==========
# ========== ashery ==========
# ========== Autobasidiomycetes ==========
# ========== bobbery ==========
# ========== amphistome ==========
# ========== bremely ==========
# ========== astral ==========
# ========== biolinguistics ==========
# ========== affrightfully ==========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment