Linux uses commands to clear the terminal screen

  

We all know that most of the Linux operations are done through commands, the average person will clear the terminal screen after use, so as not to cause unnecessary trouble, but in many cases, and Did not completely clear the terminal screen, the following small series will introduce you to Linux to completely clear the terminal screen.

There are many other ways to clear the screen, but basically it is a variant of the clear command, and can't really clear the screen.

Coincidentally, I recently found a command that can completely solve our problems.

printf “\\033c” is the order we need. It is really emptying the terminal screen, its function is similar to the CLS effect provided by CMD.EXE in DOS.

But what exactly does this command do? What is the working principle of it?

\\033 == \\x1B == 27 == ESC

So, this command becomes "ESC"c, which is expressed in VT-XXX "Full Reset (RIS) & rdquo; escape code. All the terminals we use today are VT-compatible, but if you find yourself using a very strange terminal, you probably won't be able to use this command. Printf is a built-in command in bash, and built-in commands take precedence over other executables.

We can also use another command, reset, which also clears the terminal screen, but we can still use the up and down keys to view the history commands. One disadvantage of this command is that it is a bit slow to execute, perhaps because it does not send ESC c instructions, but the compatibility of this command is obviously better than the previous one.

The reset command is very useful when your terminal is in control. Have you ever encountered an input character that does not appear at the cursor position? When you hit the Enter key, the new prompt does not appear on the new line, but appears in front of the old prompt? The reset command is to fix this problem. You can also use this command on CYGWIN.

The above is a complete description of the Linux terminal screen. Although the clear command can clear the screen, it is not complete, but can be completely cleared by using the printf “\\033c” or Reset command.

Copyright © Windows knowledge All Rights Reserved