Master `stdbuf` for Unbuffered Command Output
Quick Tip
Master `stdbuf` for Unbuffered Command Output
Challenge: When piping the output of a command to another command (e.g., `command1 | command2`), or when redirecting output to a file, some commands buffer their output. This can lead to delays in seeing real-time results, especially for logs or streaming data.
The Solution: Use the `stdbuf` command to control output buffering.
stdbuf -o L your_command_here
Why it works: The `-o L` option tells `stdbuf` to set the output buffering mode to “line buffering”. This ensures that output is flushed line by line, making it appear immediately when piped or redirected.
Pro-Tip: You can also use `-e L` for unbuffered stderr and `-i L` for unbuffered stdin if needed.
Linux Tips & Tricks | © ngelinux.com | 5/3/2026
