Master `stdbuf` for Unbuffered Command Output

Quick Tip

Master `stdbuf` for Unbuffered Command Output

Challenge: Some commands, especially those that produce output in real-time or are part of a pipeline, buffer their output. This can lead to delays in seeing results or unexpected behavior when piping data. You might notice this when running certain monitoring tools or in script execution where output isn’t immediately visible.

The Solution: Use the `stdbuf` command to control the buffering of command output.

stdbuf -oL your_command_here

Why it works: The `-o` flag tells `stdbuf` to modify the standard output buffering. Setting it to `L` (line buffering) ensures that output is flushed line by line, rather than waiting for a larger buffer to fill. This is crucial for real-time feedback and reliable piping.

Pro-Tip: You can also use `-e` for standard error buffering and `-i` for standard input buffering. For example, `stdbuf -oL -eL your_command` will line buffer both stdout and stderr.

Linux Tips & Tricks | © ngelinux.com | 4/28/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments