2

How to extract characters between delimiters ":" for all occurrences in a line (defined as strings separated by white-space) for all lines? I have tried sed 's/.:(.):.*//g' but that doesn't take into account multiple occurrences.

given:

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

to be obtained:

2.000 1.001
2.000 1.002
shellter
  • 36,525
  • 7
  • 83
  • 90
9987
  • 43
  • 4
  • Does this answer your question? [How to extract characters between the delimiters using sed?](https://stackoverflow.com/questions/7684729/how-to-extract-characters-between-the-delimiters-using-sed) – tripleee Feb 09 '21 at 08:21

1 Answers1

1

This might work for you (GNU sed):

sed -r 's/[^:]*:([^:]*):\S*(\s)*/\1\2/g' file
potong
  • 55,640
  • 6
  • 51
  • 83