1UNBUFFER(1) General Commands Manual UNBUFFER(1)
2
3
4
6 unbuffer - unbuffer output
7
9 unbuffer program [ args ]
10
12 unbuffer disables the output buffering that occurs when program output
13 is redirected from non-interactive programs. For example, suppose you
14 are watching the output from a fifo by running it through od and then
15 more.
16
17 od -c /tmp/fifo | more
18
19 You will not see anything until a full page of output has been pro‐
20 duced.
21
22 You can disable this automatic buffering as follows:
23
24
25 unbuffer od -c /tmp/fifo | more
26
27 Normally, unbuffer does not read from stdin. This simplifies use of
28 unbuffer in some situations. To use unbuffer in a pipeline, use the -p
29 flag. Example:
30
31 process1 | unbuffer -p process2 | process3
32
34 unbuffer -p may appear to work incorrectly if a process feeding input
35 to unbuffer exits. Consider:
36 process1 | unbuffer -p process2 | process3
37
38 If process1 exits, process2 may not yet have finished. It is impossi‐
39 ble for unbuffer to know long to wait for process2 and process2 may not
40 ever finish, for example, if it is a filter. For expediency, unbuffer
41 simply exits when it encounters an EOF from either its input or
42 process2.
43
44 In order to have a version of unbuffer that worked in all situations,
45 an oracle would be necessary. If you want an application-specific
46 solution, workarounds or hand-coded Expect may be more suitable. For
47 example, the following example shows how to allow grep to finish pro‐
48 cessing when the cat before it finishes first. Using cat to feed grep
49 would never require unbuffer in real life. It is merely a placeholder
50 for some imaginary process that may or may not finish. Similarly, the
51 final cat at the end of the pipeline is also a placeholder for another
52 process.
53
54
55 $ cat /tmp/abcdef.log | grep abc | cat
56 abcdef
57 xxxabc defxxx
58 $ cat /tmp/abcdef.log | unbuffer grep abc | cat
59 $ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat
60 abcdef
61 xxxabc defxxx
62 $
63
65 The man page is longer than the program.
66
67
69 "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Pro‐
70 grams" by Don Libes, O'Reilly and Associates, January 1995.
71
73 Don Libes, National Institute of Standards and Technology
74
75
76
77 1 June 1994 UNBUFFER(1)