学习笔记:curl

Marvin
2 min readDec 11, 2019

curl 我经常用来测试网站的域名解析:

curl n.n.n.n -H "Host: domain.com"curl https://www.abc.com/ --resolve 'www.abc.com:443:103.235.46.39'

curl 的结果是通过 stdout 输出的,所以需要使用 2>&1 才能用在 piping 上,这个 curl 的作者专门做了解释:

curl -v --silent https://google.com/ 2>&1 | grep expire

-v: 输出 header 信息,--silent 隐藏进度条(大文件的话),详细的 manual 文件可以这里查看:

curl 比我想象的强多了,基本上涵盖了整个「url协议」的所有内容,还可以支持批量下载和重复发起请求等等

前面 manual 文件里面有 Linux 命令行 options 约定的介绍,说的很清楚:

Options start with one or two dashes. Many of the options require an additional value next to them.

The short “single-dash” form of the options, -d for example, may be used with or without a space between it and its value, although a space is a recommended separator. The long “double-dash” form, -d, --data for example, requires a space between it and its value.

Short version options that don’t need any additional values can be used immediately next to each other, like for example you can specify all the options -O, -L and -v at once as -OLv.

In general, all boolean options are enabled with --option and yet again disabled with --no-option. That is, you use the exact same option name but prefix it with “no-”. However, in this list we mostly only list and show the --option version of them. (This concept with --no options was added in 7.19.0. Previously most options were toggled on/off on repeated use of the same command line option.)

--

--