awk - How to parse URL params in shell script -


i have tried same in python parse url params know if there way same in shell script.

say, have url value:

http://www.abcdsample.com/listservices?a=1&b=10&c=abcdeeff&d=1663889&listservices=a|b

required output:

url: http://www.abcdsample.com/ service: listservices a=1 b=10 c=abcdeeff d=1663889 listservices=a|b 

here 1 method:

begin{     fs="?" } {     url=$1     sub(/[^/]*$/,"",url)     print "url:",url      sub(/.*[/]/,"",$1)     print "service:",$1      n=split($2,b,/&/)     (i=1;i<=n;i++)         print b[i] } 

save script.awk , run awk -f script.awk file:

url: http://www.abcdsample.com/ service: listservices a=1 b=10 c=abcdeeff d=1663889 listservices=a|b 

note: work url like:


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -