I have a file (file1) with in the below format
HTML Code:
ST*820*212121
BPR*C*213212.20*C*212*CCD*01***01*071000013*DA*321321*101208
TRN*1*21321321*13213
N1*PR*3232. dff. SYS.*91*3232
ENT*1
N1*PE* 2132121321
RMR*TN*234456677888**192387.20*192387.20
REF*IV*234456677888*213213 3213 UNI
DTM*003*101122
RMR*TN*835435435323**1*1
SE*000010*3213213
I have the below mentioned awk command to fetch the RMR loop (that is ) with an account number (234456677888) as the reference.
$acct is 234456677888
HTML Code:
awk ' /'"$acct"'/&& /RMR/{print;flag=1;next} (/RMR/ || /ENT/) {flag=0} flag { print }' $tmp/file1
The above command was fetching me the RMR loop until it finds the next RMR
HTML Code:
RMR*TN*234456677888**192387.20*192387.20
REF*IV*234456677888*213213 3213 UNI
DTM*003*101122
Now the problem is when the same account number is present in the row next to the RMR (REF*IV*234456677888*213213 3213 UNI), the same command returns a different result as shown below.
HTML Code:
RMR*TN*234456677888**192387.20*192387.20
Can anyone suggest what should I do to get the same result as I was getting earlier
---------- Post updated at 06:55 AM ---------- Previous update was at 06:44 AM ----------
I could fix this by adding RMR.* before the $acct in the script.