I want sudo apt-get update
to report about what it is doing on single line rather than filling the terminal window with its output. I don't want to hide possible error messages, though.
I mean something like this, but writing the last line that changes and is not visible after that in the output of sudo apt-get update
:
sudo apt-get update | xargs -I{} printf '%-*s\r' $(tput cols) "{}"
printf '\n
Also would be nice, if it could write given number of lines, and scrolling those lines without hiding the text preceding its output in terminal window.
This will be difficult to do without writing a proper application that uses ncurses or similar to control the terminal. With bash, you can get some of this effect with the following script:
Run as
foo.sh N
where N is the number of lines you want to keep. Note that:apt-get
provides more transient output when it's printing to a terminal, so the output here will seem jerky as intermediate lines are not available.So the final output will look like: