Skip to content
Advertisement

Clear screen in a Linux terminal using assembly?

Is there a way to clear the screen in a terminal window with nasm?

By clear the screen, I mean emulate the Ctrl-L hotkey. Remove all text from the window.

Advertisement

Answer

In Bash:

echo -ne "33[H33[2J"

In C:

printf("33[H33[2J");

How do I find the string:

$ strace -e trace=write clear >/dev/null 
write(1, "33[H33[2J", 7)              = 7
Process 7983 detached
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement