使用 gawk 和 regexp 查找匹配行

Finding matching lines with gawk and regexp

我有一个包含如下行的文件:

(+0.010605625808,-0.187753006816)|000000000100> +
(-0.090206444263,+0.071405023336)|000000000101> +
(-0.090206436813,+0.071404993534)|000000000110> +
(+0.069306485355,+0.012268572114)|000000000111> +
(+0.010605554096,-0.187753051519)|000000001000> +
(-0.104045681655,+0.102472946048)|000000001001> +

我需要取两个编号列的未签名值: 例如 0.0106056258080.187753006816

这是我希望工作的 awk 行

awk '[=11=] ~ /^\((.*),/ {print  "and" }' examples.txt 

但这是输出:

(+0.217999786139,+0.216710388660)|000000000000>and+
(+0.010605582036,-0.187753096223)|000000000001>and+
(+0.010605548508,-0.187753096223)|000000000010>and+
(-0.090206362307,+0.071405015886)|000000000011>and+
(+0.010605625808,-0.187753006816)|000000000100>and+
(-0.090206444263,+0.071405023336)|000000000101>and+
(-0.090206436813,+0.071404993534)|000000000110>and+
(+0.069306485355,+0.012268572114)|000000000111>and+
(+0.010605554096,-0.187753051519)|000000001000>and+
(-0.104045681655,+0.102472946048)|000000001001>and+

我的问题出在正则表达式还是 awk 上? 谢谢。

你可以稍微简化一下

$ awk -F'[(,)]' '{gsub(/[-+]/,""); print ,}' file

0.010605625808 0.187753006816
0.090206444263 0.071405023336
0.090206436813 0.071404993534
0.069306485355 0.012268572114
0.010605554096 0.187753051519
0.104045681655 0.102472946048
awk -F'[(),+-]' '{print ,}' file