Results 1 to 4 of 4
Hi all.
I need to get the substring PRUEBAS_RMAN_PARCHES from the following string
"BP Key: 47531 Status: AVAILABLE Tag: PRUEBAS_RMAN_PARCHES"
But the position and length may vary between different strings.
...
- 12-21-2011 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 4
KSH: how to find the position of a substring in a string
Hi all.
I need to get the substring PRUEBAS_RMAN_PARCHES from the following string
"BP Key: 47531 Status: AVAILABLE Tag: PRUEBAS_RMAN_PARCHES"
But the position and length may vary between different strings.
The string will always be preceded by the other string "Tag: ", so I'd like to use it as starting point
Anybody can please tell me the easy way to do it?
Thanks a lot.
- 12-21-2011 #2
No idea, if it is possible with ksh alone, but sed can do it:
Code:echo "BP Key: 47531 Status: AVAILABLE Tag: PRUEBAS_RMAN_PARCHES" | sed 's/\(.*\)Tag: \(.*\)/\2/' PRUEBAS_RMAN_PARCHES
You must always face the curtain with a bow.
- 12-21-2011 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 4
Yes, that's exactly what I was looking for.
Thanks
- 12-21-2011 #4
Be aware though, that this simple regex will take anything after "Tag: " until the end of the line.
If there are other columns following, you probably need a more complex one that matches all the cases of your data.You must always face the curtain with a bow.


Reply With Quote