Last active
October 22, 2021 13:07
-
-
Save wilhelm-murdoch/b92b692673033faa3acb0da3758decdd to your computer and use it in GitHub Desktop.
Convert text to "spongebob' format from your command line ...
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
#!/usr/bin/env bash | |
set -eo pipefail | |
[[ -n "${VERBOSE}" ]] && set -x | |
read text | |
while [[ $index -lt "${#text}" ]]; do | |
swap=$(( $RANDOM % 10 )) | |
char="${text:$index:1}" | |
if [[ "${swap}" -lt 5 ]] ; then | |
echo -n "${char}" | tr '[[:lower:]]' '[[:upper:]]' | |
elif [[ "${swap}" -lt 3 ]]; then | |
echo -n "${char}" | tr '[[:upper:]]' '[[:lower:]]' | |
else | |
echo -n "${char}" | |
fi | |
index=$(( $index + 1 )) | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
${HOME}/bin/spongebob
.chmod a+x "${HOME}/bin/spongebob"
$PATH
.echo 'This is SpongeBob text!' | spongebob
from anywhere.