

tput: Portable Terminal Control

The tput command allows shell scripts to do things like clear the screen, underline text, and center text no matter how wide the screen is. To do these things, it translates the terminal-independent name of a terminal capability into its actual value for the terminal type being used.

tput takes as an argument the name of a Unix System V terminfo capability, which it translates into the equivalent termcap capability name (see section Capabilities, for a list of the equivalencies). Terminfo is a database that is similar to termcap but which has different capability names and is stored in a different format. The GNU tput command takes a terminfo name as an argument to make it compatible with the Unix System V tput command.

There are three types of terminfo (and termcap) capabilities: string, Boolean, and numeric. String capabilities either cause a special effect on the terminal when they are displayed or are the value sent by a special key on the terminal (the latter type are probably of no use in shell scripts). Numeric and Boolean capabilities give information about the terminal such as how many columns wide it is or whether whether it has a meta key. See section Output and Exit Status, for more detailed information on the three types of capabilities.

The format of the tput command is illustrated below.

tput [options] capability [parameter ...]
tput [options] longname
tput [options] init
tput [options] reset

GNU tput takes the following options:

[-T terminal-type] [--terminal=terminal-type]
[-t] [--termcap]
[-S] [--standard-input]
[-V] [--version]

Here is an example of how to clear the terminal screen using tput:

tput clear
