Skip to content

Instantly share code, notes, and snippets.

@shinkbr
Last active November 20, 2017 02:18
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 shinkbr/aacad1564a525dbf915dbec2871969ce to your computer and use it in GitHub Desktop.
Save shinkbr/aacad1564a525dbf915dbec2871969ce to your computer and use it in GitHub Desktop.
URI encode / decode strings.
#!/usr/bin/env bash
usage () {
echo "Usage: $( basename $0 ) <e|d>"
}
if [ "$#" -ne 1 ]; then
usage
exit 1
fi
if [ "$1" = "e" ]; then
cat - | ruby -ruri -ne 'print URI.encode($_)'
elif [ "$1" = "d" ]; then
cat - | ruby -ruri -ne 'print URI.decode($_)'
else
usage
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment