Created
November 16, 2023 22:22
-
-
Save evnm/1a3c77aa1bf9e51833d05fad4655d42c to your computer and use it in GitHub Desktop.
A shell command which prints its input wItH AlTeRnAtInG LoWeR AnD UpPeRcAsInG.
This file contains 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/sh | |
# A shell command which prints its input wItH AlTeRnAtInG LoWeR AnD | |
# UpPeRcAsInG. | |
# | |
# Example: | |
# $ echo "we're all trying to find who did this" | spongebob | |
# wE'Re aLl tRyInG To fInD WhO DiD ThIs | |
<&0 awk ' | |
{ | |
split($0, chars, "") | |
for (i=1; i <= length($0); i++) { | |
printf "%s", i % 2 == 0 ? toupper(chars[i]) : tolower(chars[i]) | |
} | |
printf "\n" | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment