I am trying to parse the output of a command that expects to be writing to the screen. It has data separated by move-to-origin control sequences (for the VT220, ESC[1;1H). I only need the last part (i.e. after the last move-to-origin).
I have tried doing this multiple ways (primarily awk and sed), but the problem is always that parts of the control sequence have special meaning (to the program, not just to the shell), and I cannot quote them when I substitute tput's output.
Here is an example of what I am looking to parse (ESC is the escape character):
Page 1; line 1 Page 1; line 2 ESC[1;1HPage 2; line 1 Page 2; line 2 ESC[1;1HPage 3; line 1 Page 3; line 2
I am looking to get the following, which is what would be on the terminal after the program has run.
Page 3; line 1 Page 3; line 2