← 返回命令列表

Linux command

unbuffer 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run command with unbuffered output

unbuffer [command]

Unbuffer in a pipeline

[command1] | unbuffer -p [command2] | [command3]

Unbuffer grep in a pipeline

tail -f [logfile] | unbuffer -p grep [pattern]

Unbuffer output of a script

unbuffer ./[script.sh] | tee [output.log]

说明

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.

参数

-p
Pipeline mode: read from stdin and pass to program.

FAQ

What is the unbuffer command used for?

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.

How do I run a basic unbuffer example?

Run `unbuffer [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p do in unbuffer?

Pipeline mode: read from stdin and pass to program.