为什么awk print'声明忽略了我的行中的标题吗?

发布于 2025-01-22 07:14:16 字数 716 浏览 3 评论 0 原文

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location

返回以下内容:

location: /en-US/docs/Web/API/fetch

我的问题是为什么尴尬的“打印”语句忽略标题,而唯一的打印路径如下:

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location | awk '{ print $2 }'

结果:

/en-us/docs/web/api/fetch

In MDN's command line introduction they print a network response heading to stdout.

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location

which returns this:

location: /en-US/docs/Web/API/fetch

My question is why does the awk 'print' statement ignore the header and only print path like below:

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location | awk '{ print $2 }'

result:

/en-us/docs/web/api/fetch

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘东忘西忘不掉你 2025-01-29 07:14:16

您可以尝试

awk '{ print $0 }'

$ 2:打印第二列
$ 0:打印所有列

you can try

awk '{ print $0 }'

$2 : print the second column
$0 : print all columns

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文