Tail seems to parse TTY commands. When commands use ^M to erase the line & redraw the line in stdout, for example an animated ASCII progress bar.
When I tail a file where this is happening, I see the animated progress bar. I want to capture a single "frame" from tail & write it to another file.
Here's what I see when I view the file using tail
3%
Here's what I see with less
or when I try to parse the log programmatically.
^M0%^M1%^M3%
I want to create a file that just contains "3%", or whatever the latest 'frame' of animation is. I want a command that captures what I as a human physically see on my screen, and writes it to a file.
For a bit of context - its for a web app. I want to have the browser poll for the latest status & replace the contents of a div to. I need a command that outputs the latest "frame" suitable for this use case.
Also an acceptable solution would be the stream the file live over websockets, and parse the file client side. Preferably though there exists some command or flag I can pass to tail
to do this easily.