Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Why doesn't 'clear' actually erase the console?
1 point by bikamonki on Feb 9, 2015 | hide | past | favorite | 3 comments
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?



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"




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: