LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

unbuffer

Disable output buffering for commands

TLDR

Run command with unbuffered output
$ unbuffer [command]
copy
Unbuffer in a pipeline
$ [command1] | unbuffer -p [command2] | [command3]
copy
Unbuffer grep in a pipeline
$ tail -f [logfile] | unbuffer -p grep [pattern]
copy
Unbuffer output of a script
$ unbuffer ./[script.sh] | tee [output.log]
copy

SYNOPSIS

unbuffer [-p] program [args]

DESCRIPTION

unbuffer disables output buffering that occurs when program output is redirected. Many programs buffer their output when not connected to a terminal, which can cause delays or issues in pipelines.The tool works by connecting the program to a pseudo-terminal (pty), making it behave as if running interactively. This forces line-buffered or unbuffered output even when redirected to files or pipes.Common use cases include watching log files through grep, capturing colored output, and ensuring real-time output in scripts.unbuffer is part of the Expect package and uses Expect's pty handling capabilities.

PARAMETERS

-p

Pipeline mode: read from stdin and pass to program.
program
The command to run with unbuffered output.
args
Arguments to pass to the program.

INSTALL

sudo apt install expect
copy
sudo dnf install expect
copy
sudo pacman -S expect
copy
sudo apk add expect
copy
sudo zypper install expect
copy
brew install expect
copy
nix profile install nixpkgs#expect
copy

CAVEATS

Does not read from stdin by default; use -p for pipeline mode. In pipeline mode with -p, unbuffer exits immediately when it encounters EOF. May affect programs that detect terminal capabilities. Part of the expect package, not installed by default on all systems.

HISTORY

unbuffer was created as part of the Expect package by Don Libes at NIST. Expect is documented in "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" (O'Reilly, 1995). The tool addresses a common Unix problem of output buffering in pipelines.

SEE ALSO

expect(1), stdbuf(1), script(1), tee(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid