Here are a couple more Unix aliases, this time for quickly escaping and unescaping URL query parameters. These are defined in my ~/.bash_aliases file.
alias urlencode="perl -MURI::Escape -ple '\$_=uri_escape(\$_); s/%20/+/g'"
alias urldecode="perl -MURI::Escape -ple '\$_=uri_unescape(\$_); s/\+/ /'"
To escape/encode all unsafe characters in a query parameter:
$ echo "blue socks?" | urlencode
blue+socks%3F
And to unescape/decode a parameter:
$ echo blue+socks%3F | urldecode
blue socks?
These aliases depend on Perl and the URI::Escape module which are standard on most modern Unixes.
2 comments:
Thhanks for the post
Hi great reaading your blog
Post a Comment