Sorry for the confusion. I was trying to turn a Windows batch script into Python, that used grep + sed + tail, but you're right, the meat was in the grep + sed.
The following works to find two close by slightly different patterns starting from the end of the file:
Thank you!
The following works to find two close by slightly different patterns starting from the end of the file:
pattern = "^START_A.+to (.+?) \(.+$" p = re.compile(pattern) for line in reversed(list(open(INPUTFILE))): m = p.search(line.rstrip()) if m: print(m.group(1)) break pattern = "^START_B.+to (.+?) \(.+$" p = re.compile(pattern) for line in reversed(list(open(INPUTFILE))): m = p.search(line.rstrip()) if m: print(m.group(1)) breakI'll see if I can refine it so as to avoid needless copy/pasting.
Thank you!