Help needed with an awk command

I have a file: tmp_file
(contents of tmp_file)

DEVICE_111 vss vss dss lsv w 1.16e-07 l 2e-08 la 0 m 1 param 1 ng 1 lp 0 f 1 adcc 1.296e-14 as 1.296e-14
DEVICE_112 vss dss dss lsv w 1.22e-07 l 2e-08 la 0 m 1 param 1 ng 1 lp 0 f 1 adcc 1.296e-14 as 1.296e-14
DEVICE_113 vss dss vss ccv w 1.86e-07 l 2e-08 la 0 m 1 param 1 ng 1 lp 0 f 1 adcc 1.296e-14 as 1.296e-14
DEVICE_114 dss dss dss lvc w 1.2e-07 l 2e-08 la 0 m 1 param 1 ng 1 lp 0 f 1 accd 1.296e-14 as 1.296e-14
DEVICE_115 vss vss dss cvw w 1.55e-07 l 2e-08 la 0 m 1 param 1 ng 1 lp 0nf 1 ccad 1.296e-14 as 1.296e-14

I am using grep + awk command to verify and list certain parameters:
command used:

grep -n -i "w" tmp_file | awk -v key=w -v num=0.0 -v 'BEGIN {IGNORECASE = 1} {for(i=2;i<=NF;i++){if ($i==key  && $(i+1) ~ /^[0-9.e+e-]+$/ && sprintf("%.30f",$(i+1)) > sprintf("%.30f",num)) print $1":"$i"="$(i+1)":"$(i+2)"="$(i+3)":"$(i+6)"="$(i+7)}}'

Output:

1:DEVICE_111:w=1.16e-07:l=2e-08:m=1
2:DEVICE_112:w=1.22e-07:l=2e-08:m=1
3:DEVICE_113:w=1.86e-07:l=2e-08:m=1
4:DEVICE_114:w=1.2e-07:l=2e-08:m=1
5:DEVICE_115:w=1.55e-07:l=2e-08:m=1

New Requirement:
I want to multiply the values of w, l and m, which are exponential values

$(i+1) * $(i+3) * $(i+7)

How to append this command for the new requirement??

Try

awk -vKEYARR="w m l"  '
BEGIN   {for (n=split (KEYARR, TMP); n; n--) KEYS[TMP[n]]
        }
        {RES = 1
         for (i=1; i<=NF; i++) if ($i in KEYS) RES*=$(i+1)
         print RES
        }
' file
1 Like

Thanks a lot RudiC ... the code worked ....

---------- Post updated at 06:47 AM ---------- Previous update was at 06:46 AM ----------

I used

 awk -vKEYARR="w m l"  ' BEGIN   {for (n=split (KEYARR, TMP); n; n--) KEYS[TMP[n]] } {RES = 1; for (i=1; i<=NF; i++) if ($i in KEYS) RES*=$(i+1); print RES}' tmp_file 

---------- Post updated at 06:47 AM ---------- Previous update was at 06:47 AM ----------

had put it in a single line ....

Thanks again