---------- Post updated at 10:31 AM ---------- Previous update was at 10:28 AM ----------
Hello,
I am trying to get the string cut based on the following needs:
String1=Submitted request 25574824 for CONCURRENT SQLAP RUAPACTUALSEXT Y RUAPACTUALS122313100616.dat "2013/01/12 14:50:44" "2013/01/16 16:20:21" Normal completion
I need to look for the LAST occurrence of string2 in string1 (in this example there is only one occurrence) and get the rest of the text in string1 by ignoring the first space.
In the above example, I am looking for output of
Normal completion
Any help is greatly appreciated.
>echo $string1
Submitted request 25574824 for CONCURRENT SQLAP RUAPACTUALSEXT Y RUAPACTUALS122313100616.dat "2013/01/12 14:50:44" "2013/01/16 16:20:21" Normal completion
>echo $string2
RUAPACTUALS122313100616.dat "2013/01/12 14:50:44" "2013/01/16 16:20:21"
>echo <some unix command to get the output>
Normal completion
Presuming that you are at the shell prompt or in a shell script and that you want to get the last bit of $string1, but how should we split it? You would need to tell us:-
What format the string will always be in (space delimited, fixed width, number of fields etc.
What other output apart from Normal completion we will have to expect
There are lots of ways to do this, but it would be best if you can steer us what you are considering and therefore you will learn better with what you are familiar with.
Format of string 1 is space delimited, but can have any number of fields.
'Normal completion' is just one output. It could have any number of fields in place of 'Normal completion'
I have tried the following cut command, but keep getting invalid delimiter. Even if it worked, it may give me only 'Normal' as the output.