Para borrar la pantalla de la consola y el búfer de desplazamiento hacia atrás cuando se ejecuta PuTTY, esto funciona para mí:
echo -en "\ec\e[3J"
En realidad, se trata de 2 secuencias "Esc" que actúan de forma independiente ... se pueden usar en cualquier orden:
# 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"
El uso de echo -en "\ec"que restablece el terminal puede cambiar algunas de sus otras configuraciones de terminal. En lugar de "Restablecer", puede hacer esto:
# 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"
Puede poner esto en un script de shell y funciona bien.
En caso de que haya algunas dependencias del sistema:
Estoy usando PuTTY Connection Manager (Versión 0.7.1 BETA (compilación 136)), con PuTTY (Versión 0.60).
Mecanografía:
echo \"$TERM\"; /bin/sh --version
informes:
"xterm"
GNU bash, version 4.1.2(1)-release-(x86_64-redhat-linux-gnu) ...