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