Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active January 2, 2016 23:58
Show Gist options
  • Select an option

  • Save coderofsalvation/8379355 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8379355 to your computer and use it in GitHub Desktop.
converts special htmlcharacters into htmlentities
# converts special htmlcharacters into htmlentities
# usage: cat file.txt | htmlentities
htmlentities(){
cat - | sed -e 's/&/\&/g' \
-e 's/</\&lt;/g' \
-e 's/>/\&gt;/g' \
-e 's/ä/\&auml;/g' \
-e 's/ö/\&ouml;/g' \
-e 's/ü/\&uuml;/g' \
-e 's/ß/\&szlig;/g' \
-e 's/Ä/\&Auml;/g' \
-e 's/Ö/\&Ouml;/g' \
-e 's/Ü/\&Uuml;/g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment