使用URL字符串正确格式化curl url

Ton*_*ark 3 curl

我试图让curl使用以下形式的url:

http://www.example.com?a=1&b=2
Run Code Online (Sandbox Code Playgroud)

但是,一直只是这样http://www.example.com?a=1,我可以通过使用-v标志来判断.

我正在使用的命令是:

curl http://www.example.com?a=1&b=2
Run Code Online (Sandbox Code Playgroud)

如何在查询中为多个URL字符串正确使用curl?

Ada*_*kin 5

&你的shell正在拦截" "(它试图让它在后台运行,你可能没有注意到它,因为它仍会输出到同一个控制台).尝试引用网址:

curl 'http://www.example.com?a=1&b=2'
Run Code Online (Sandbox Code Playgroud)

如果有疑问,请尝试将所有参数传递给其他人echo,看看会发生什么.这是我的shell的示例脚本:

$ echo foo&bar
[1] 18759
foo
bash: bar: command not found
[1]+  Done                    echo foo
$ echo foo\&bar
foo&bar
$ echo "foo&bar"
foo&bar
$ echo 'foo&bar'
foo&bar
Run Code Online (Sandbox Code Playgroud)