Unbuffer
Script error: No such module "AfC submission catcheck".
Unbuffer is a command for Unix-like systems that runs another command in a pseudoterminal (PTY) such as to have the effect that the command's standard output is directly connected to a terminal or terminal emulator. This can be useful to disable buffering, as per its namesake; it is also useful for commands that detect the output device and behave differently, to force the normal behaviour, such as to keep ANSI colour enabled even if output is being piped into another process/command. The unbuffer
command is written in Tool Command Language (Tcl) and is bundled with the Expect project.[1]
Examples[edit]
NVLC's lengthy help output produces colour-coded presentation of headings, options, and arguments to ease navigation and reading – but only if it detects that its stdout is connected to a terminal device, or something that behaves as such. Contrarily, it is common practice to pipe such lengthy output into a pager, such as less
, for example, to avoid flooding one's terminal. If NVLC detects that its output is a pipe then it disables its colour formatting, even though less
can display colour using the -R
option. To manage the lengthy output both with colour and with paging, the unbuffer
command can be employed, as follows:-
unbuffer nvlc --help | less -M -R
The ls
command (from GNU Coreutils, at least) supports the option --colour=always
, eliminating the need for unbuffer
in this instance. However, there are other behaviours of ls
for which unbuffer may still be useful, such as for its tabulation. Normally the output of ls
is tabulated, making better use of the full width of the terminal; but when piped, ls
disables its tabulation:-
$ ls --color=always /proc/ | head --lines=2 1 10
To restore the tabulation, unbuffer
can be applied in the same way as before:-
$ unbuffer ls --color=always /proc/ | head --lines=2 1 13971 18 2124 25516 31093 369 7104 90 kpagecount 10 14 1812 2126 25561 31972 3696 729 9025 kpageflags
References[edit]
This Unix-related article is a stub. You can help EverybodyWiki by expanding it. |
This article "Unbuffer" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Unbuffer. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.