awk
to the rescue?
$ awk -F"[: ]" '{print $2":"$3}' file
474D229F698D494E889D85CEF9303B97:480
474D229F698D494E889D85CEF9303B97:480
Explanation: we define different possible field separators :
or space . Once the text has been splitted, then we print the 2nd and 3rd field.
sed
way could be the following:
$ sed 's/UID:\([^:]*\):\([^ ]*\).*/Captured:\1:\2/g' file
Captured:474D229F698D494E889D85CEF9303B97:480
Captured:474D229F698D494E889D85CEF9303B97:480
Explanation: We see the text is based on the pattern UID:number:number something
. Hence, we get it with UID:\([^:]*\):\([^ ]*\).*
. With \( expression \)
we capture the text we need, so that it can be printed later on with \1
, \2
...