Created
April 16, 2024 19:26
-
-
Save AbeEstrada/c1598f1dce973b6744ec85f94c1f7521 to your computer and use it in GitHub Desktop.
A script to decode html entities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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