Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
Created April 16, 2024 19:26
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 AbeEstrada/c1598f1dce973b6744ec85f94c1f7521 to your computer and use it in GitHub Desktop.
Save AbeEstrada/c1598f1dce973b6744ec85f94c1f7521 to your computer and use it in GitHub Desktop.
A script to decode html entities
#!/usr/bin/env zsh
if [ -t 0 ]; then
# Argument
input="$1"
else
# STDIN
input="$(cat /dev/stdin)"
fi
if [ -z "$input" ]; then
echo "Error: No input provided." >&2
exit 1
fi
decoded=$(perl -CS -MHTML::Entities -ne 'print decode_entities($_)' <<< "$input")
echo "$decoded"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment