ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example

I look for primary and * to isolate the interesting slot number.


slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'`

Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk indicates the interesting slot, "Slot 1"

sed -n '/\s+"$gslot"/p; /Touch:/p'

Output

My question is :
How do I get only the Touch line following the Slot 1 line ? (marked that interesting line with a "-G"

Ofcourse I could have missed something, ... looking through books and the web but I havent found anything that addresses this issue.

Try something like this worked with given sample

$ awk '/\*|Touch:/{if(gsub(/\*/,x))$0=$1 FS $2;print}' file

Slot 1
Touch: CTSDEV.1-9-6-2R-K9.P1.SPA
Touch: CTSDEV.1-9-6-2R-K9.P1.SPA-G

How about this:

awk '
/^primary$/ {ARMED=1}
ARMED==1 && /^\*/ {SLOT=$2}
$1="Slot" && $2==SLOT{ARMED=2}
/^Touch:/ && ARMED==2{print "Slot " SLOT;print; SLOT=ARMED=0}' infile