Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A one liner to parse a http query string in bash
#
# the following one liner creates a shell variable from every parameter in a
# the query string in the variable QUERY, of the form p1=v1&p2=v2,... and sets it to
# the corresponding value so that parameters can be accessed by its name $p1, $p2, ...
#
for p in ${QUERY//&/ };do kvp=( ${p/=/ } ); k=${kvp[0]};v=${kvp[1]};eval $k=$v;done
@mstyles

This comment has been minimized.

Copy link

@mstyles mstyles commented Apr 30, 2015

👍

@Shulyaka

This comment has been minimized.

Copy link

@Shulyaka Shulyaka commented Sep 24, 2019

What about http://localhost/cgi-bin/script.sh?reboot;a=a ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.