Ask HN: Why doesn't 'clear' actually erase the console?
If I run clear on a re-sized console window in Linux all goes away but when I maximize that window everything is there, clear just scrolls console contents?
3 comments
Yes. I think its a special code that the program sends to the terminal. It comes from the days terminals used to be fisical instead of virtual. Its in the termcap database that corresponds to the terminal you use.
I always thought it just printed empty lines based on window height.
So when you scrolled up, stuff was still there.
This code works on my terminal: \e[1;1H\e[2J
So try printf "\e[1;1H\e[2J"