Last active
November 20, 2017 02:18
-
-
Save shinkbr/aacad1564a525dbf915dbec2871969ce to your computer and use it in GitHub Desktop.
URI encode / decode strings.
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 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