shell下解码url
http://aaronw.me/static/779.html
封装了一下,有需要的拿走
function url_decode() { local url=$1 echo $url | awk 'BEGIN { for(i=0;i<10;i++) hex[i]=i; hex["A"]=hex["a"]=10; hex["B"]=hex["b"]=11; hex["C"]=hex["c"]=12; hex["D"]=hex["d"]=13; hex["E"]=hex["e"]=14; hex["F"]=hex["f"]=15; } { gsub(/\+/," "); i=$0; while(match(i,/%../)) { if(RSTART>1); printf"%s",substr(i,1,RSTART-1); printf"%c",hex[substr(i,RSTART+1,1)]*16+hex[substr(i,RSTART+2,1)]; i=substr(i,RSTART+RLENGTH); } print i; }' - }
url="http%3A%2F%2Fclub.fir.im%2Ftopic%2F546abf22ba23eab90aa29c99&aid=1619&nid=51"
url_decode $url
http://club.fir.im/topic/546abf22ba23eab90aa29c99&aid=1619&nid=51