stdbuf
Adjust stream buffering of commands
TLDR
Line buffered stdout
SYNOPSIS
stdbuf [-i mode] [-o mode] [-e mode] command [args]
DESCRIPTION
stdbuf runs a command with modified standard stream buffering. When programs detect their output is going to a pipe rather than a terminal, they typically switch from line-buffered to fully-buffered output, which delays output. stdbuf overrides this behavior using LD_PRELOAD to intercept buffering calls.
The three modes are: line-buffered (L) which flushes after each newline, unbuffered (0) which flushes immediately, and a specific buffer size. This is particularly useful when piping output through filters like grep or awk where real-time output is needed rather than waiting for the buffer to fill.
PARAMETERS
-i MODE
stdin buffering.-o MODE
stdout buffering.-e MODE
stderr buffering.
MODES
L - Line buffered
0 - Unbuffered
SIZE - Buffer size (e.g., 1K, 1M)
CAVEATS
Doesn't work with all programs. Statically linked programs unaffected. Some use internal buffering.
HISTORY
stdbuf is part of GNU coreutils. It uses LD_PRELOAD to intercept buffering calls.
