I was recently trying to learn more about how the shell works and was looking at how the clear
command works. The executable is located in /usr/bin/clear
and it seems to print out a bunch of blank lines (equal to the height of the terminal) and puts the cursor at the top-left of the terminal.
The output of the command is always the same, regardless of the size of the terminal:
$ clear | hexdump -C
00000000 1b 5b 48 1b 5b 32 4a |.[H.[2J|
00000007
and can be replicated with the echo having the exact same effect:
$ /bin/echo -e "\x1b\x5b\x48\x1b\x5b\x32\x4a\c"
I was really curious how this output of this command translates to clearing the console.
stty -a
– mikeserv yesterday