Skip to content

Instantly share code, notes, and snippets.

@dwnoble
Created February 23, 2012 19:05
Show Gist options
  • Save dwnoble/1894405 to your computer and use it in GitHub Desktop.
Save dwnoble/1894405 to your computer and use it in GitHub Desktop.
Replace characters that have Spanish accents with non accented characters
#!/bin/sh
# Note: input should end with a newline
LINES=''
while read LINE; do
LINES="${LINES}\n${LINE}"
done
echo $LINES | sed 's/á/a/g' | sed 's/Á/A/g' | sed 's/é/e/g' | sed 's/É/E/g' | sed 's/í/i/g' | sed 's/Í/I/g' | sed 's/ó/o/g' | sed 's/Ó/O/g' | sed 's/ú/u/g' | sed 's/Ú/U/g' | sed 's/ñ/n/g' | sed 's/Ñ/N/g' | sed 's/ü/u/g' | sed 's/Ü/U/g'
exit 0
@Dedalus27
Copy link

Why not:

echo $LINES | sed -e 's/à/a/g' -e 's/Á/A/g'  . . .  -e 's/Ü/U/g'

and so on?

@ameisehaufen
Copy link

Or:

sed -e "s/\./ /g; . . . ;s/-/ /g;s/)//g"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment