xref: /freebsd/usr.bin/fold/fold.1 (revision 5bb3134a8c21cb87b30e135ef168483f0333dabb)
1.\" Copyright (c) 1980, 1993
2.\"	The Regents of the University of California.  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 must retain the above copyright
8.\"    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.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)fold.1	8.1 (Berkeley) 6/6/93
29.\" $FreeBSD$
30.\"
31.Dd October 29, 2020
32.Dt FOLD 1
33.Os
34.Sh NAME
35.Nm fold
36.Nd "fold long lines for finite width output device"
37.Sh SYNOPSIS
38.Nm
39.Op Fl bs
40.Op Fl w Ar width
41.Op Ar
42.Sh DESCRIPTION
43The
44.Nm
45utility is a filter which folds the contents of the specified files,
46or the standard input if no files are specified,
47breaking the lines to have a maximum of 80 columns.
48.Pp
49The options are as follows:
50.Bl -tag -width indent
51.It Fl b
52Count
53.Ar width
54in bytes rather than column positions.
55.It Fl s
56Fold line after the last blank character within the first
57.Ar width
58column positions (or bytes).
59.It Fl w Ar width
60Specify a line width to use instead of the default 80 columns.
61The
62.Ar width
63value
64should be a multiple of 8 if tabs are present, or the tabs should
65be expanded using
66.Xr expand 1
67before using
68.Nm .
69.El
70.Sh ENVIRONMENT
71The
72.Ev LANG , LC_ALL
73and
74.Ev LC_CTYPE
75environment variables affect the execution of
76.Nm
77as described in
78.Xr environ 7 .
79.Sh EXAMPLES
80Fold text in standard input with a width of 20 columns:
81.Bd -literal -offset indent
82$ echo "I am smart enough to know that I am dumb" | fold -w 15
83I am smart enou
84gh to know that
85 I am dumb
86.Ed
87.Pp
88Same as above but breaking lines after the last blank character:
89.Bd -literal -offset indent
90$ echo "I am smart enough to know that I am dumb" | fold -s -w 15
91I am smart
92enough to know
93that I am dumb
94.Ed
95.Sh SEE ALSO
96.Xr expand 1 ,
97.Xr fmt 1
98.Sh STANDARDS
99The
100.Nm
101utility conforms to
102.St -p1003.1-2001 .
103.Sh HISTORY
104The
105.Nm
106utility first appeared in
107.Bx 1 .
108It was rewritten for
109.Bx 4.3 Reno
110to improve speed and modernize style.
111The
112.Fl b
113and
114.Fl s
115options were added to
116.Nx 1.0
117for
118.St -p1003.2
119compliance.
120.Sh AUTHORS
121.An -nosplit
122.An Bill Joy
123wrote the original version of
124.Nm
125on June 28, 1977.
126.An Kevin Ruddy
127rewrote the command in 1990, and
128.An J. T. Conklin
129added the missing options in 1993.
130.Sh BUGS
131If underlining (see
132.Xr ul 1 )
133is present it may be messed up by folding.
134