korn shell - how to find the position of a string within a string
Posted on 2013-06-13
I have a string that I need to find and extract the "connect phrase" from it.
Here is an example string:
allocate channel c43 device type disk maxopenfiles 1 format '/u2/backup/TMKT/database/backup_%d_<static_date_seq>_%t%s%p' connect 'sys/<connect_pwd>@TMKT14';
(that's one continuous string regardless of the formatting here)
What I need to do is:
1. find the position of "connect"
2. extract from the connect to the second single quote (')
The resulting extracted string in the example above would be:
The catch is that I do not know where this occurs in the string because there are differing formats of the string, and the connect phrase itself is different between strings (in other words, it will not always be what is in the example above).
Any help is much appreciated!