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