trurl 是由 curl 作者 Daniel Stenberg 新开发的,一个用于解析和操作 URL 的小型命令行工具,旨在帮助各地的 shell 脚本作者。
trurl 是一个类似于 tr 的工具,但用于 URL。URL 很难解析,因此软件中存在许多安全问题;trurl希望通过让各地的脚本和命令行作者不再重复发明轮子来帮助缓解这个问题。
trurl 使用 libcurl 的 URL 解析器,因此解析和理解 URL 的方式与命令行工具 curl 完全相同,两者可以作为配套工具使用。
示例:
$ trurl --url https://curl.se --set host=example.com
https://example.com/
$ trurl --set host=example.com --set scheme=ftp
ftp://example.com/
$ trurl --url https://curl.se/we/are.html --redirect here.html
https://curl.se/we/here.html
$ trurl --url https://curl.se/we/../are.html --set port=8080
https://curl.se:8080/are.html
$ trurl --url https://curl.se/we/are.html --get '{path}'
/we/are.html
$ trurl --url https://curl.se/we/are.html --get '{port}'
443
$ trurl https://example.com/hello.html --get '{scheme} {port} {path}'
https 443 /hello.html
$ trurl --url https://curl.se/hello --append path=you
https://curl.se/hello/you
$ trurl --url "https://curl.se?name=hello" --append query=search=string
https://curl.se/?name=hello&search=string
$ trurl --url-file url-list.txt --get '{host}'
[one host name per URL in the input file]
$ cat url-list.txt | trurl --url-file - --get '{host}'
[one host name per URL in the input file]
评论