Quick Tip
Harnessing `stdbuf` for Unbuffered Command Output
Challenge: When running commands in a script or pipeline, especially those that generate output incrementally (like logging or certain data processing tools), the output might be buffered. This means you won’t see the results in real-time, which can be frustrating for debugging or monitoring.
The Solution: Use the `stdbuf` command to control the buffering of standard input, output, and error streams.
stdbuf -oL your_command_here
Why it works: The `-o L` flag tells `stdbuf` to set the standard output stream to line buffering. This ensures that output is flushed line by line, making it visible as it’s generated.
Pro-Tip: You can also use `-e L` for unbuffered standard error or `-i L` for unbuffered standard input if needed.
Linux Tips & Tricks | © ngelinux.com | 4/26/2026
