How can I filter the output from a "self-updating" program such as
top while keeping its functionality intact?
For example, I want to highlight my user name in
top's output. My idea is to use something such as this:
top | grep --color -E "user|$"
It works insofar as the user name gets indeed highlighted, however, the cursor isn't where it should be in the top program and the last line is missing.
I have had similar results with other interactive shell programs such as wget (trying to highlight the progress bar using escape sequences) and rsync. How can I properly filter output from an interactive program?