unbuffer − unbuffer output


unbuffer program [ args ]


unbuffer disables the output buffering that occurs when program output is redirected from non-interactive programs. For example, suppose you are watching the output from a fifo by running it through od and then more.

od -c /tmp/fifo | more

You will not see anything until a full page of output has been produced.

You can disable this automatic buffering as follows:

unbuffer od -c /tmp/fifo | more

Normally, unbuffer does not read from stdin. This simplifies use of unbuffer in some situations. To use unbuffer in a pipeline, use the -p flag. Example:

process1 | unbuffer -p process2 | process3


unbuffer -p may appear to work incorrectly if a process feeding input to unbuffer exits. Consider:
process1 | unbuffer -p process2 | process3

If process1 exits, process2 may not yet have finished. It is impossible for unbuffer to know long to wait for process2 and process2 may not ever finish, for example, if it is a filter. For expediency, unbuffer simply exits when it encounters an EOF from either its input or process2.

In order to have a version of unbuffer that worked in all situations, an oracle would be necessary. If you want an application-specific solution, workarounds or hand-coded Expect may be more suitable. For example, the following example shows how to allow grep to finish processing when the cat before it finishes first. Using cat to feed grep would never require unbuffer in real life. It is merely a placeholder for some imaginary process that may or may not finish. Similarly, the final cat at the end of the pipeline is also a placeholder for another process.

$ cat /tmp/abcdef.log | grep abc | cat
xxxabc defxxx
$ cat /tmp/abcdef.log | unbuffer grep abc | cat
$ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat
xxxabc defxxx


The man page is longer than the program.


"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" by Don Libes, O’Reilly and Associates, January 1995.


Don Libes, National Institute of Standards and Technology

More Linux Commands

iscsiuio(8) iSCSI UserSpace I O driver - Linux manual page
iscsiuio is the UserSpace I/O driver for the Broadcom NetXtreme II BCM5706/5708/5709 series PCI/PCI-X Gigabit Ethernet Network Interface Card (NIC) and for the

perfmonctl(2) interface to IA-64 performance monitoring unit
The IA-64-specific perfmonctl() system call provides an interface to the PMU (performance monitoring unit). The PMU consists of PMD (performance monitoring data

XInternalConnectionNumbers(3) - handle Xlib internal connect
The XAddConnectionWatch function registers a procedure to be called each time Xlib opens or closes an internal connection for the specified display. The procedu

setusershell(3) - get permitted user shells - Linux man page
setusershell.3 - The getusershell() function returns the next line from the file /etc/shells, opening the file if necessary. The line should contain the pathnam

gftp(1) file transfer client for NIX based machines.........
gFTP is a file transfer client for *NIX based machines. It currently has a text interface and a GTK+ 1.2/2.x graphical interface. It currently supports the FTP,

kunittestmodrunner(1) manual page for Qt 4.8.6 (Man Page)...
A command-line application that can be used to run KUnitTest modules. Generic options: --help Show help about options --help-qt Show Qt specific options --help-

x0vncserver(1) TigerVNC Server for X displays (Man Page)....
x0vncserver is a TigerVNC Server which makes any X display remotely accessible via VNC, TigerVNC or compatible viewers. Unlike Xvnc(1), it does not create a vir

glutTimerFunc(3) - registers a timer callback to be triggere
glutTimerFunc registers the timer callback func to be triggered in at least msecs milliseconds. The value parameter to the timer callback will be the value of t

TYPE_REGEXP(3form) - form system global variables (ManPage)
These are building blocks for the form library, defining fields that can be created using set_fieldtype(3X). Each provides functions for field- and character-va

glIndexiv(3gl) - set the current color index (Man Page).....
glIndex updates the current (single-valued) color index. It takes one argument, the new value for the current color index. The current index is stored as a floa

glGetHistogramParameter(3gl) - get histogram parameters.....
glGetHistogramParameter is used to query parameter values for the current histogram or for a proxy. The histogram state information may be queried by calling gl

gnutls_priority_set_direct(3) - API function (Man Page).....
Sets the priorities to use on the ciphers, key exchange methods, macs and compression methods. This function avoids keeping a priority cache and is used to dire

We can't live, work or learn in freedom unless the software we use is free.