sed 提取特定分隔符之间每次出现的字符串

sed extract every occurrence of string between specific delimiters

如何为所有行提取一行中出现的所有分隔符“:”之间的字符(定义为由白色-space 分隔的字符串)? 我试过 sed 's/.:(.):.*//g' 但这没有考虑多次出现。

给定:

1/1:2.000:0.000,0.000,1.000 0/1:1.001:0.000,0.999,0.001
1/1:2.000:0.000,0.000,1.000 0/1:1.002:0.000,0.998,0.002

待获得:

2.000 1.001
2.000 1.002

这可能适合您 (GNU sed):

sed -r 's/[^:]*:([^:]*):\S*(\s)*//g' file