Harnessing `stdbuf` for Unbuffered Command Output

Quick Tip

Harnessing `stdbuf` for Unbuffered Command Output

Challenge: When running commands or scripts that produce output intermittently, you might want to see that output immediately without waiting for a buffer to fill. This is common when debugging or monitoring long-running processes.

The Solution: Use the `stdbuf` command to control buffering for your commands.

stdbuf -o L your_command [arguments]

Why it works: The `-o L` flag tells `stdbuf` to set the standard output stream to be line-buffered. This means output will be flushed line by line, ensuring you see it as soon as it’s generated.

Pro-Tip: You can also use `-e L` for unbuffered standard error, or `-i L` to set line buffering for standard input, though `-o L` is the most frequently used for immediate output visibility.

Linux Tips & Tricks | © ngelinux.com | 5/21/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments