fmt.1 5.4 KB

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