stdbuf1
Change standard streams initial buffering
Usage
stdbuf [-e
bufdef]
[-i
bufdef]
[-o
bufdef]
[command
[]]
Overview
stdbuf is used to change the initial buffering of standard input, standard output and/or standard error streams for command. It relies on libstdbuf(3) which is loaded and configured by stdbuf through environment variables.
The options are as follows:
-
-e bufdef -
Set initial buffering of the standard error stream for command as defined by bufdef (see BUFFER DEFINITION).
-
-i bufdef -
Set initial buffering of the standard input stream for command as defined by bufdef (see BUFFER DEFINITION).
-
-o bufdef -
Set initial buffering of the standard output stream for command as defined by bufdef (see BUFFER DEFINITION).
Buffer definition
The buffer style and size is defined as follows:
- "0"
-
unbuffered
- "L"
-
line buffered
- "B"
-
fully buffered with the default buffer size
- size
-
fully buffered with a buffer of size bytes (suffixes 'k' and 'M' are accepted)
Examples
In the following example, the stdout stream of the awk(1) command will be fully buffered by default because it does not refer to a terminal. stdbuf is used to force it to be line-buffered so iostat(8)'s output will not stall until the full buffer fills.
# iostat 1 | stdbuf -o L awk '$2 > 1 || $5 > 1' | cat -n
Releases
Unchanged in 13 releases since macOS 15.0.