Skip to content

Instantly share code, notes, and snippets.

@evnm
Created November 16, 2023 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evnm/1a3c77aa1bf9e51833d05fad4655d42c to your computer and use it in GitHub Desktop.
Save evnm/1a3c77aa1bf9e51833d05fad4655d42c to your computer and use it in GitHub Desktop.
A shell command which prints its input wItH AlTeRnAtInG LoWeR AnD UpPeRcAsInG.
#! /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