]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/fmt/fmt.1
strerror.3: Fix whitespace issue introduced in r368714
[FreeBSD/FreeBSD.git] / usr.bin / fmt / fmt.1
1 .\" Copyright (c) 1980, 1990, 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 .\"     @(#)fmt.1       8.1 (Berkeley) 6/6/93
29 .\" $FreeBSD$
30 .\"
31 .\" Modified by Gareth McCaughan to describe the new version of `fmt'
32 .\" rather than the old one.
33 .Dd October 29, 2020
34 .Dt FMT 1
35 .Os
36 .Sh NAME
37 .Nm fmt
38 .Nd simple text formatter
39 .Sh SYNOPSIS
40 .Nm
41 .Op Fl cmnps
42 .Op Fl d Ar chars
43 .Op Fl l Ar num
44 .Op Fl t Ar num
45 .Op Ar goal Oo Ar maximum Oc | Fl Ns Ar width | Fl w Ar width
46 .Op Ar
47 .Sh DESCRIPTION
48 The
49 .Nm
50 utility is a simple text formatter which reads the concatenation of input
51 files (or standard input if none are given) and produces on standard
52 output a version of its input with lines as close to the
53 .Ar goal
54 length
55 as possible without exceeding the
56 .Ar maximum .
57 The
58 .Ar goal
59 length defaults
60 to 65 and the
61 .Ar maximum
62 to 10 more than the
63 .Ar goal
64 length.
65 Alternatively, a single
66 .Ar width
67 parameter can be specified either by prepending a hyphen to it or by using
68 .Fl w .
69 For example,
70 .Dq Li fmt -w 72 ,
71 .Dq Li fmt -72 ,
72 and
73 .Dq Li fmt 72 72
74 all produce identical output.
75 The spacing at the beginning of the input lines is preserved in the output,
76 as are blank lines and interword spacing.
77 Lines are joined or split only at white space; that is, words are never
78 joined or hyphenated.
79 .Pp
80 The options are as follows:
81 .Bl -tag -width indent
82 .It Fl c
83 Center the text, line by line.
84 In this case, most of the other
85 options are ignored; no splitting or joining of lines is done.
86 .It Fl m
87 Try to format mail header lines contained in the input sensibly.
88 .It Fl n
89 Format lines beginning with a
90 .Ql \&.
91 (dot) character.
92 .It Fl p
93 Allow indented paragraphs.
94 Without the
95 .Fl p
96 flag, any change in the amount of whitespace at the start of a line
97 results in a new paragraph being begun.
98 .It Fl s
99 Collapse whitespace inside lines, so that multiple whitespace
100 characters are turned into a single space.
101 (Or, at the end of a
102 sentence, a double space.)
103 .It Fl d Ar chars
104 Treat the
105 .Ar chars
106 (and no others) as sentence-ending characters.
107 By default the
108 sentence-ending characters are full stop
109 .Pq Ql \&. ,
110 question mark
111 .Pq Ql \&?
112 and exclamation mark
113 .Pq Ql \&! .
114 Remember that some characters may need to be
115 escaped to protect them from your shell.
116 .It Fl l Ar number
117 Replace multiple spaces with tabs at the start of each output
118 line, if possible.
119 Each
120 .Ar number
121 spaces will be replaced with one tab.
122 The default is 8.
123 If
124 .Ar number
125 is 0, spaces are preserved.
126 .It Fl t Ar number
127 Assume that the input files' tabs assume
128 .Ar number
129 spaces per tab stop.
130 The default is 8.
131 .El
132 .Pp
133 The
134 .Nm
135 utility
136 is meant to format mail messages prior to sending, but may also be useful
137 for other simple tasks.
138 For instance,
139 within visual mode of the
140 .Xr ex 1
141 editor (e.g.,
142 .Xr vi 1 )
143 the command
144 .Pp
145 .Dl \&!}fmt
146 .Pp
147 will reformat a paragraph,
148 evening the lines.
149 .Sh ENVIRONMENT
150 The
151 .Ev LANG , LC_ALL
152 and
153 .Ev LC_CTYPE
154 environment variables affect the execution of
155 .Nm
156 as described in
157 .Xr environ 7 .
158 .Sh EXAMPLES
159 Center the text in standard input:
160 .Bd -literal -offset indent
161 $ echo -e 'The merit of all things\enlies\enin their difficulty' | fmt -c
162                      The merit of all things
163                                lies
164                        in their difficulty
165 .Ed
166 .Pp
167 Format the text in standard input collapsing spaces:
168 .Bd -literal -offset indent
169 $ echo -e 'Multiple   spaces    will be collapsed' | fmt -s
170 Multiple spaces will be collapsed
171 .Ed
172 .Sh SEE ALSO
173 .Xr fold 1 ,
174 .Xr mail 1
175 .Sh HISTORY
176 The
177 .Nm
178 command appeared in
179 .Bx 3 .
180 .Pp
181 The version described herein is a complete rewrite and appeared in
182 .Fx 4.4 .
183 .Sh AUTHORS
184 .An Kurt Shoens
185 .An Liz Allen
186 (added
187 .Ar goal
188 length concept)
189 .An Gareth McCaughan
190 .Sh BUGS
191 The program was designed to be simple and fast \- for more complex
192 operations, the standard text processors are likely to be more appropriate.
193 .Pp
194 When the first line of an indented paragraph is very long (more than
195 about twice the goal length), the indentation in the output can be
196 wrong.
197 .Pp
198 The
199 .Nm
200 utility is not infallible in guessing what lines are mail headers and what
201 lines are not.