xref: /freebsd/usr.bin/stdbuf/stdbuf.1 (revision 834063202a16592e1ef5c3a9fbd04ca5f1df3ed0)
1.\" Copyright (c) 2012 Jeremie Le Hen <jlh@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code and documentation must retain the above
8.\"    copyright notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd April 28, 2012
28.Dt STDBUF 1
29.Os
30.Sh NAME
31.Nm stdbuf
32.Nd change standard streams initial buffering
33.Sh SYNOPSIS
34.Nm
35.Op Fl e Ar bufdef
36.Op Fl i Ar bufdef
37.Op Fl o Ar bufdef
38.Op Ar command Op ...
39.Sh DESCRIPTION
40.Nm
41is used to change the initial buffering of standard input,
42standard output and/or standard error streams for
43.Ar command .
44It relies on
45.Xr libstdbuf 3
46which is loaded and configured by
47.Nm
48through environment variables.
49.Pp
50The options are as follows:
51.Bl -tag -width Ds
52.It Fl e Ar bufdef
53Set initial buffering of the standard error stream for
54.Ar command
55as defined by
56.Ar bufdef
57.Pq see Sx BUFFER DEFINITION .
58.It Fl i Ar bufdef
59Set initial buffering of the standard input stream for
60.Ar command
61as defined by
62.Ar bufdef
63.Pq see Sx BUFFER DEFINITION .
64.It Fl o Ar bufdef
65Set initial buffering of the standard output stream for
66.Ar command
67as defined by
68.Ar bufdef
69.Pq see Sx BUFFER DEFINITION .
70.El
71.Sh BUFFER DEFINITION
72Buffer definition is the same as in
73.Xr libstdbuf 3 :
74.Bl -tag -width size -offset indent
75.It Qq 0
76unbuffered
77.It Qq L
78line buffered
79.It Qq B
80fully buffered with the default buffer size
81.It Ar size
82fully buffered with a buffer of
83.Ar size
84bytes (suffixes 'k', 'M' and 'G' are accepted)
85.El
86.Sh EXAMPLES
87In the following example, the stdout stream of the
88.Xr awk 1
89command
90will be fully buffered by default because it does not refer
91to a terminal.
92.Nm
93is used to force it to be line-buffered so
94.Xr vmstat 8 Ns 's
95output will not stall until the full buffer fills.
96.Bd -literal -offset indent
97# vmstat 1 | stdbuf -o L awk '$2 > 1 || $3 > 1' | cat -n
98.Ed
99.Sh SEE ALSO
100.Xr libstdbuf 3 ,
101.Xr setvbuf 3
102.Sh HISTORY
103The
104.Nm
105utility first appeared in
106.Fx 8.4 .
107.Sh AUTHORS
108.An -nosplit
109The original idea of the
110.Nm
111command comes from
112.An Padraig Brady
113who implemented it in the GNU coreutils.
114.An Jeremie Le Hen
115implemented it on
116.Fx .
117