URI decode script

Ever seen a URI like "http%3a%2f%2fklo-2k.spaces.live.com%2fdefault.aspx"? Wish you can decode it or paste it into your address bar? Well, I’ve got just the script for you:



# Idea from http://www.linuxquestions.org/questions/linux-software-2/bash-scripting-pipe-input-to-script-vs.-1-570945/#post2998640
if (( $# > 0 )); then
	param=$1	# Read from 1st parameter
	param=$(cat)	# Read from pipe

eval "echo $(echo $param|sed -e "s/&/\&/Ig" -e "s/%([a-z0-9][a-z0-9])/$'\x1'/Ig")"

Call it "uridecode", chmod +x it, then you can do something like:

firefox $(uridecode http%3a%2f%2fklo-2k.spaces.live.com%2fdefault.aspx)

Nice eh!?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: