UNBUFFER(1)
π UNBUFFER(1) π
okay bestie, welcome to the General Commands Manual glow-up edition of unbuffer β yes, that's the command name, yes it's literally just "unbuffer", lowercase, iconic, no notes. sit down, grab a strawberry π, and let's get into it.
β¨ NAME β¨
unbuffer β unbuffer output. that's it. that's the whole vibe. the name is the job description π
πΈ SYNOPSIS πΈ
unbuffer program [ args ]
you give it a program, you give it some args, and it runs that whole thing. simple as. π«Ά
π¦ INTRODUCTION π¦
so here's the tea, bestie. unbuffer disables the output buffering that happens when a program's output gets redirected from non-interactive programs. like, the buffering that sneaks in and makes you think your terminal is ghosting you. π
say you're watching the output from a fifo by running it through od and then more, like this:
od -c /tmp/fifo | more
you will not see anything until a full page of output has been produced. not a crumb. not a single character. the silence is loud. π
but you can disable that automatic buffering like this, and it's giving instant gratification:
unbuffer od -c /tmp/fifo | more
β¨ slay. now here's a little plot twist you should know about: normally, unbuffer does not read from stdin. nope, not doing it. this simplifies use of unbuffer in some situations (lowkey a feature, not a bug, trust).
but if you do want to use unbuffer in a pipeline? that's what the -p flag is for, bestie. example time:
process1 | unbuffer -p process2 | process3
look at that pipeline. main character energy. π
π CAVEATS π
okay so this is the part where we get real. unbuffer -p may appear to work incorrectly if a process feeding input to unbuffer exits. consider this situation:
process1 | unbuffer -p process2 | process3
if process1 exits, process2 may not yet have finished. and here's the thing β it is impossible for unbuffer to know how long to wait for process2, and process2 may not ever finish. for example, if it is a filter. it just... keeps going. forever. a filter with no chill. π
for expediency, unbuffer simply exits when it encounters an EOF from either its input or process2. it's not being rude, it's being efficient.
in order to have a version of unbuffer that worked in all situations, an oracle would be necessary. yes, an actual oracle. we don't have one. π
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. they're all just little actors in the pipeline theatre. π
$ cat /tmp/abcdef.log | grep abc | cat
abcdef
xxxabc defxxx
$ cat /tmp/abcdef.log | unbuffer grep abc | cat
$ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat
abcdef
xxxabc defxxx
$
see how the second one just... says nothing? yeah. that's the whole caveat. π
π BUGS π
the man page is longer than the program.
(that's it. that's the bug. and honestly? it's iconic. not me being a whole manual with more lore than code. π)
π SEE ALSO π
- "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" by Don Libes, O'Reilly and Associates, January 1995. π
π AUTHOR π
Don Libes, National Institute of Standards and Technology. legend behaviour, fr fr. π«Ά
and that's the page, bestie!! this whole thing comes to you from the General Commands Manual collection β UNBUFFER(1), dated 1 June 1994, which is giving vintage but make it timeless. πβ¨ go forth and unbuffer, you've got this. π
πΈ
π¦ where this page comes from
- debian bookworm: expect 5.45.4-2+b1
- ubuntu jammy: expect 5.45.4-2build1
- ubuntu noble: expect 5.45.4-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms