原件:
Mac终端REGEX的行为略有不同。我可以使用以下示例在我的Mac上执行此操作:
$ curl google.com | sed 's/]*>//g'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 219 100 219 0 0 385 0 --:--:-- --:--:-- --:--:-- 385
301 Moved
301 Moved
The document has moved
here.
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
编辑:
为了澄清起见,原始文字看起来像:
$ curl googl.com
301 Moved301 Moved
The document has moved
here.
还可以使用-s选项摆脱恼人的curl标头:
$ curl -s google.com | sed 's/]*>//g'
301 Moved
301 Moved
The document has moved
here.
$