In my code, I am searching for a string and trying to print along with it, the two lines above it.
My command outputs to a text file file.txt which then contains multiple sequences of three distinct key pairs.
For example:
Principle: principle name
profile:profile name
Authadd:CRT,DLT,PASSID
Principle: principle name
profile:profile name
Authadd:CRT,CHG,PASSID
Principle: principle name
profile:profile name
Authadd:CRT,INQ,PASSID
Principle: principle name
profile:profile name
Authadd:CRT,PASSID
Authadd is the last in each sequence of three entries.
AUTHADD has many values like CRT,DLT,CHG,PASSID,SETALL, we have to only capture the entries which have CRT Or DLT and print the above two lines like Principle and Profile values.
I don't see any command, or code, for a Windows batch script to fetch the lines above the search string; like grep -a2 in Unix.
Can someone help me with the command, if any, to get the lines above the search string?