Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 为什么要输出进程名?如何摆脱它?_Bash_Curl - Fatal编程技术网

Bash 为什么要输出进程名?如何摆脱它?

Bash 为什么要输出进程名?如何摆脱它?,bash,curl,Bash,Curl,通常,使用cURL时,输出如下所示: alex$ curl http://some-url some-content 但是,对于某些URL,输出是不同的: alex$ curl http://some-url [1] 81030 alex$ some-content [1]+ Done curl http://some-url 为什么会发生这种情况,以及如何消除这种情况并使cURL只输出内容 如果某个url包含&字符,则shell将其解释为在后台运行进

通常,使用cURL时,输出如下所示:

alex$ curl http://some-url
some-content
但是,对于某些URL,输出是不同的:

alex$ curl http://some-url
[1] 81030
alex$ some-content
[1]+  Done                    curl http://some-url

为什么会发生这种情况,以及如何消除这种情况并使cURL只输出内容

如果某个url包含
&
字符,则shell将其解释为在后台运行进程的命令

要克服它,你可以用
\&
(前加反斜杠)避开
&

是有帮助的,凯文在没有具体信息的情况下推断出你的具体问题,值得表扬

让我补充一下一般性建议:

与其通过
\
-前缀来单独转义shell元字符(对shell具有特殊意义的字符),不如考虑:

  • 将文字括在单引号中;e、 g.:
    curl'http://example.org/search&query=foo“

  • 将变量引用括在双引号中;e、 g.:
    url=http://example.org/search&query=foo'; 卷曲“$url”

这样,你就不必担心要逃离哪个角色了

通常,如果您明确希望shell解释无引号的文本/变量引用,则只使用无引号的文本/变量引用