Thoroughly clear the screen in CentOS

Source: Internet
Author: User

Thoroughly clear the screen in CentOS

Linux users, especially Ubuntu or CentOS users, are basically usedclearCommand orCtrl+LCombine shortcuts to clear the terminal screen. However, this operation does not actually clear the screen. It just gives people the illusion that the screen is cleared. However, when you scroll up with the mouse, you can still see the output from the previous command operations. When processing a large amount of text, this situation will cause us trouble.

There are many other ways to clear the screen on the Internet, but they are basicallyclearCommand variants. So how can we truly clear the screen?

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

printf “\033c”It is exactly the command we need. It truly clears the terminal screen. Its functions are similar to those in DOS.CMD.EXEProvidedCLSThe results are similar.

But what exactly is this command? How does it work?

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

As a result, this command becomes <ESC> c, which is the escape code in the VT-XXX that represents "Full Reset (RIS. All the terminals we use today are VT compatible, but if you find yourself using a very strange terminal, you may not be able to use this command.printfIt is a built-in command in bash. the built-in command has a higher priority than other executable files.

We can also use another command,resetIt also clears the terminal screen, but we can still use the up and down keys to view historical commands. One disadvantage of this command is that it is a little slow to execute, maybe because it has not been sentESC cCommand, but the compatibility of this command is obviously better than the previous one.

resetCommands are useful when your terminal is in disorder. Have you ever encountered a situation where the input character cannot appear at the cursor position? When you press the Enter key, the new prompt does not appear on the new line, but in front of the old prompt?resetThe command is used to fix this problem. You can also use this command on CYGWIN.

[How-to-clear-terminal-screen-for-real]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.