]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/fold/fold.1
fold(1): Add EXAMPLES section
[FreeBSD/FreeBSD.git] / usr.bin / fold / fold.1
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
43 The
44 .Nm
45 utility is a filter which folds the contents of the specified files,
46 or the standard input if no files are specified,
47 breaking the lines to have a maximum of 80 columns.
48 .Pp
49 The options are as follows:
50 .Bl -tag -width indent
51 .It Fl b
52 Count
53 .Ar width
54 in bytes rather than column positions.
55 .It Fl s
56 Fold line after the last blank character within the first
57 .Ar width
58 column positions (or bytes).
59 .It Fl w Ar width
60 Specify a line width to use instead of the default 80 columns.
61 The
62 .Ar width
63 value
64 should be a multiple of 8 if tabs are present, or the tabs should
65 be expanded using
66 .Xr expand 1
67 before using
68 .Nm .
69 .El
70 .Sh ENVIRONMENT
71 The
72 .Ev LANG , LC_ALL
73 and
74 .Ev LC_CTYPE
75 environment variables affect the execution of
76 .Nm
77 as described in
78 .Xr environ 7 .
79 .Sh EXAMPLES
80 Fold 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
83 I am smart enou
84 gh to know that
85  I am dumb
86 .Ed
87 .Pp
88 Same 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
91 I am smart
92 enough to know
93 that I am dumb
94 .Ed
95 .Sh SEE ALSO
96 .Xr expand 1 ,
97 .Xr fmt 1
98 .Sh STANDARDS
99 The
100 .Nm
101 utility conforms to
102 .St -p1003.1-2001 .
103 .Sh HISTORY
104 The
105 .Nm
106 utility first appeared in
107 .Bx 1 .
108 It was rewritten for
109 .Bx 4.3 Reno
110 to improve speed and modernize style.
111 The
112 .Fl b
113 and
114 .Fl s
115 options were added to
116 .Nx 1.0
117 for
118 .St -p1003.2
119 compliance.
120 .Sh AUTHORS
121 .An -nosplit
122 .An Bill Joy
123 wrote the original version of
124 .Nm
125 on June 28, 1977.
126 .An Kevin Ruddy
127 rewrote the command in 1990, and
128 .An J. T. Conklin
129 added the missing options in 1993.
130 .Sh BUGS
131 If underlining (see
132 .Xr ul 1 )
133 is present it may be messed up by folding.