To clear the console screen and the scrollback buffer when running PuTTY, this works for me:
echo -en "\ec\e[3J"
This is actually 2 "Esc" sequences that act independently... they can be used in either order:
# clears the console screen, but not the scrollback buffer
# this is actually the escape code to "reset" the terminal
echo -en "\ec"
# clears the scrollback buffer, but not the console screen
# screen content remains, and cursor position remains at its last position
echo -en "\e[3J"
echo -en "\ec" which resets the terminal might change some of your other terminal settings. Instead of "Reset", you could do this:
# position the cursor to "Home" (Top Row, First Column)
echo -en "\e[H"
# Erase down: clear the screen from the cursor down to the bottom of the screen.
echo -en "\e[J"
# Note: this is supposed to clear the screen and position the cursor to home,
# but it didn't work like that for me. It cleared the entire screen (above and
# below the cursor), but left the cursor at its last position.
echo -en "\e[2J"
# putting everything together
echo -en "\e[H\e[J\e[3J"
You can put this in a shell script and it works just fine.
In case there are some system dependencies:
I'm using PuTTY Connection Manager (Version 0.7.1 BETA (build 136)), with PuTTY (Release 0.60).
echo \"$TERM\"; /bin/sh --version
GNU bash, version 4.1.2(1)-release-(x86_64-redhat-linux-gnu) ...