clear - Man Page

clear the terminal screen

Examples (TL;DR)

Synopsis

clear [-x] [-T terminal-type]

clear -V

Description

clear clears your terminal's screen and its scrollback buffer, if any. clear retrieves the terminal type from the environment variable TERM, then consults the terminfo terminal capability database entry for that type to determine how to perform these actions.

The capabilities to clear the screen and scrollback buffer are named “clear” and “E3”, respectively. The latter is a user-defined capability, applying an extension mechanism introduced in ncurses 5.0 (1999).

Options

clear recognizes the following options.

-T type

produces instructions suitable for the terminal type. Normally, this option is unnecessary, because the terminal type is inferred from the environment variable TERM. If this option is specified, clear ignores the environment variables LINES and COLUMNS as well.

-V

reports the version of ncurses associated with this program and exits with a successful status.

-x

prevents clear from attempting to clear the scrollback buffer.

Portability

Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor X/Open Curses Issue 7 documents clear.

The latter documents tput, which could be used to replace this utility either via a shell script or by an alias (such as a symbolic link) to run tput as clear.

History

A clear command using the termcap database and library appeared in 2BSD (1979). Eighth Edition Unix (1985) later included it.

The commercial Unix arm of AT&T adapted a different BSD program (tset) to make a new command, tput, and replaced the clear program with a shell script that called “tput clear”.

/usr/bin/tput ${1:+-T$1} clear 2> /dev/null
exit

In 1989, when Keith Bostic revised the BSD tput command to make it similar to AT&T's tput, he added a clear shell script as well.

exec tput clear

The remainder of the script in each case is a copyright notice.

In 1995, ncurses's clear began by adapting BSD's original clear command to use terminfo. The E3 extension came later.

See Also

tput(1), xterm(1), terminfo(5)

Referenced By

dialog(1), setterm(1), tabs(1), terminfo(5), tput(1), user_caps(5).

2023-12-16 ncurses 6.4 User commands