admin管理员组文章数量:1398780
I'm trying to use grep to extract a response header from a curl request and for some reason .*
and .+
won't match anything but .
and ...
etc will. It's like the *
and +
operators just don't work. Example:
curl 'ifconfig.me' -v 2>&1 | grep -Po '< via: \K.+'
Swap .
with \w
and nothing changes. But
curl 'ifconfig.me' -v 2>&1 | grep -Po '< via: \K.......'
matches something, but not everything. The moment I add *
or +
to my pattern everything breaks.
Is it because I'm piping stderr to stdout with 2>&1
? Is that confusing grep somehow?
I can work around this with curl --write-out '%{header_json}' and extract with
jq` but I'm very confused why my first approach didn't work.
本文标签: grepWhy don39tand * work when parsing a curl response headersStack Overflow
版权声明:本文标题:grep - Why don't + and * work when parsing a curl response headers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744633229a2616668.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论