Miscellaneous
tput
Query and set terminal capabilities using the terminfo database.
Synopsis
syntax
tput [OPTION]... CAPNAME [PARM]...
Examples
Get terminal width in columns
tput cols
Get terminal height in lines
tput lines
Print bold text then reset
tput bold; echo 'BOLD'; tput sgr0
Print green text
tput setaf 2; echo 'green'; tput sgr0
Common options
| Flag | Description |
|---|---|
| cols | Print number of columns |
| lines | Print number of lines |
| bold | Start bold mode |
| sgr0 | Reset formatting |
| setaf | Set foreground color |
About tput
The `tput` command query and set terminal capabilities using the terminfo database. Utility commands cover a broad range of everyday tasks from date manipulation and arithmetic to terminal control and system documentation.
These tools fill in the gaps between major categories and are frequently used in shell scripts, cron jobs, and interactive sessions. The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man tput`).
The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Miscellaneous Commands
Other commands in the Miscellaneous category