gpurl
is small shell utility to extract parts from a URL. It uses go standard library URL parser to parse URLs. gpurl
is written as a UNIX cli tool, you can pass the URLs as arguments separated by space or piped into stdin
Get it with go get
go get github.com/dbalan/gpurl
This will create the gpurl executable under your $GOPATH/bin
directory.
gpurl extracts parts from a url. It uses parser from go standard library.
Urls can be passed as arguments or piped via stdin
Usage:
gpurl [flags] [urls]
Flags:
-e, --empty-error error if extracted part is empty
-h, --help help for gpurl
-p, --part string part of the url to extract, could be host, scheme, path (default "host")
% gpurl -p host http://dbalan.in/hello
dbalan.in
% gpurl -p path http://dbalan.in/hello
/hello
% echo http://dbalan.in/hello | gpurl -p path -e
/hello