Site icon New Generation Enterprise Linux

Harnessing `stdbuf` for Unbuffered Command Output

Quick Tip

Harnessing `stdbuf` for Unbuffered Command Output

Challenge: Many commands buffer their output, especially when piped. This can delay real-time analysis or monitoring, as you won’t see output until the buffer is full or the command finishes.

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

stdbuf -o L your_command_here

Why it works: The `-o L` flag tells `stdbuf` to set the standard output stream to be line-buffered. This ensures that each line of output from `your_command_here` is immediately flushed, even if the buffer isn’t full.

Pro-Tip: You can also use `-e L` for line-buffering standard error and `-i L` for line-buffering standard input, though the latter is less commonly needed for output-related issues.

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

0 0 votes
Article Rating
Exit mobile version