xref: /freebsd/usr.bin/stdbuf/stdbuf.1 (revision 1719886f6d08408b834d270c59ffcfd821c8f63a)
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.Dd April 28, 2012
26.Dt STDBUF 1
27.Os
28.Sh NAME
29.Nm stdbuf
30.Nd change standard streams initial buffering
31.Sh SYNOPSIS
32.Nm
33.Op Fl e Ar bufdef
34.Op Fl i Ar bufdef
35.Op Fl o Ar bufdef
36.Op Ar command Op ...
37.Sh DESCRIPTION
38.Nm
39is used to change the initial buffering of standard input,
40standard output and/or standard error streams for
41.Ar command .
42It relies on
43.Xr libstdbuf 3
44which is loaded and configured by
45.Nm
46through environment variables.
47.Pp
48The options are as follows:
49.Bl -tag -width Ds
50.It Fl e Ar bufdef
51Set initial buffering of the standard error stream for
52.Ar command
53as defined by
54.Ar bufdef
55.Pq see Sx BUFFER DEFINITION .
56.It Fl i Ar bufdef
57Set initial buffering of the standard input stream for
58.Ar command
59as defined by
60.Ar bufdef
61.Pq see Sx BUFFER DEFINITION .
62.It Fl o Ar bufdef
63Set initial buffering of the standard output stream for
64.Ar command
65as defined by
66.Ar bufdef
67.Pq see Sx BUFFER DEFINITION .
68.El
69.Sh BUFFER DEFINITION
70Buffer definition is the same as in
71.Xr libstdbuf 3 :
72.Bl -tag -width size -offset indent
73.It Qq 0
74unbuffered
75.It Qq L
76line buffered
77.It Qq B
78fully buffered with the default buffer size
79.It Ar size
80fully buffered with a buffer of
81.Ar size
82bytes (suffixes 'k', 'M' and 'G' are accepted)
83.El
84.Sh EXAMPLES
85In the following example, the stdout stream of the
86.Xr awk 1
87command
88will be fully buffered by default because it does not refer
89to a terminal.
90.Nm
91is used to force it to be line-buffered so
92.Xr vmstat 8 Ns 's
93output will not stall until the full buffer fills.
94.Bd -literal -offset indent
95# vmstat 1 | stdbuf -o L awk '$2 > 1 || $3 > 1' | cat -n
96.Ed
97.Sh SEE ALSO
98.Xr libstdbuf 3 ,
99.Xr setvbuf 3
100.Sh HISTORY
101The
102.Nm
103utility first appeared in
104.Fx 8.4 .
105.Sh AUTHORS
106.An -nosplit
107The original idea of the
108.Nm
109command comes from
110.An Padraig Brady
111who implemented it in the GNU coreutils.
112.An Jeremie Le Hen
113implemented it on
114.Fx .
115