Skip to content

Instantly share code, notes, and snippets.

@ldante86
Created November 16, 2016 06:25
Show Gist options
  • Save ldante86/79de4e724693b60eed5379291e975761 to your computer and use it in GitHub Desktop.
Save ldante86/79de4e724693b60eed5379291e975761 to your computer and use it in GitHub Desktop.
Text to Pig Latin
#!/bin/bash -
#
# SCRIPT: igpay
# AUTHOR: Luciano D. Cecere
# DATE: 10/18/2014-04:29:05 PM
#
########################################################################
#
# igpay - convert standard input to standard pig latin :@)
# Copyright (C) 2014 Luciano D. Cecere <ldante86@aol.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
export PATH=/bin:/usr/bin
unalias -a
declare -l words
_pigout()
{
local prefix=${1%%[aeiouy]*}
local suffix=$(sed 's/^[bcdfghjklmnpqrstvxwz]*//' <<< $1)
case ${1:0:2} in
qu) printf "${1:2}${1:0:2}ay "
return ;;
esac
case ${1:0:1} in
[aeiou]) printf "${suffix}${prefix}way " ;;
[0-9] ) printf "$1 " ;;
* ) printf "${suffix}${prefix}ay " ;;
esac
}
while read words
do
for i in $words
do
_pigout $i
done
printf "\n\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment