set x "22/OBGJ/123456_5.66:22/OBGJ/000123_7.134" ;# This is your string
puts "[string range $x 0 [expr [string first ":" $x] - 1]]" ;# [string first ":" $x] gives you the index of the first ":" and use [expr theposition - 1] to get the index - 1 position, then string range just extract out the substring
I should clarify that this is for tcl, not shell scripting.
I was not able to find a Tcl related channel, I apologize if this is not the best place to pose the question.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
set x "22/OBGJ/123456_5.66:22/OB
puts "[string range $x 0 [expr [string first ":" $x] - 1]]" ;# [string first ":" $x] gives you the index of the first ":" and use [expr theposition - 1] to get the index - 1 position, then string range just extract out the substring