I am writing a ksh script and the above solutions as mentioned in the my previous question How to parse a string in unix and get a value
are not working for dynamic value search. I have modified the question to suit my requirement.
I have a string as below
MON_DT ="BD0 $DATE_BD0|BD1 $DATE_BD1|BD2 $DATE_BD2|BD3 $DATE_BD3|BD4 $DATE_BD4|BD5 $DATE_BD5"MON_DT
CHK_DT='jun 25 2013'
Values of the Variables are like this.
DATE_BD0 = "apr 1 2014"
DATE_BD1 = "mar 31 2103"
DATE_BD2 = "Feb 3 2012"
DATE_BD3 = "Jan 22 2013"
DATE_BD4 = "may 21 2013"
DATE_BD5 = "jun 25 2013"
DATE_BD6 = "jul 27 2013"
Now I need to search $CHK_DT form the $MON_DT string and get the value BD5.
as mentioned in the example, As matter $CHK_DT dynamically changes we need to get the appropriate BD values accordingly.
As in the I want the Result as BD5.
Can some one Answer this query, this is very urgent for me. Thanks in advance.