小编w00*_*00t的帖子

在同一行 curl 命令后回显文本

#!/bin/bash
echo "$(curl -s -I https://google.com|grep Server)" abc
Run Code Online (Sandbox Code Playgroud)

返回:

abcer: gws
Run Code Online (Sandbox Code Playgroud)

bash -x显示:

++ grep Server
++ curl -s -I https://google.com
' abco 'Server: gws
 abcer: gws
Run Code Online (Sandbox Code Playgroud)

echo abc "$(curl -s -I https://google.com|grep Server)"` 
Run Code Online (Sandbox Code Playgroud)

返回

abc Server: gws
Run Code Online (Sandbox Code Playgroud)

换句话说,如果我在 curl 命令之后添加文本,它会被破坏,但是如果我在 curl 之前添加它就可以了。
怎么了?我想不明白。

http curl newlines

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

curl ×1

http ×1

newlines ×1