#!/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 之前添加它就可以了。
怎么了?我想不明白。