[Turn] on several techniques for clearing the screen under linux

In the DOS interface of windows, the command to clear the screen is cls, so what is the command to clear the screen in linux? Below, the author shares several methods of clearing the screen that have been used under linux.

1. The clear command . This command will refresh the screen. In essence, it just makes the terminal display page turn back one page. If you scroll up the screen, you can also see the previous operation information.

2. Ctrl+l (lowercase L) , this is a shortcut key for clearing the screen. This is the clearing method that I use most in my work. The clearing effect is the same as the clear command.

3. The reset command . This command will completely refresh the terminal screen, and the previous terminal input operation information will be cleared. Although this is relatively refreshing, the entire command process is a bit slow and less used.

    It is worth mentioning that the reset command is very useful when your terminal control is messed up. Such as the input character does not appear at the position of the cursor. Also when you hit enter, the new prompt doesn't appear on a new line

    Instead, it appears in front of the old prompt. The reset command can then be used to fix these problems.

4, printf "\033c" command ,

    This command really clears the terminal screen, and its function is very similar to the CLS effect provided by CMD.EXE in DOS. But what exactly does this command do? How does it work?

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

    Thus, this command becomes <ESC>c, which is the escape code for "Full Reset (RIS)" in VT-XXX. All the terminals we use today are VT compatible, and another implementation of it could be this:

    On the keyboard, Ctrl+v--->Esc-->Enter c and add it back. But if you find yourself using a very strange terminal (as I have tested on putty), this command may not work for you.

    printf is a built-in command in bash, and the built-in command has higher priority than other executable files.

Through the comparison of the above four clearing methods, the author likes it, under the PATH path, such as /usr/bin/ directory. Create a new file named cls, add execute permission , and write the content as entered:

In this case, every time we need to clear the screen, we only need to enter the cls command.

 

Original

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324641023&siteId=291194637