↑↑↑ Home | ↑↑ UNIX | ↑ Updateware |
The text formatter fmt is a standard tool that breaks text into lines. It is rather sophisticated but narrow in purpose. For example, it cannot simply concatenate every paragraph into a single line because of an arbitrary restriction on the line width.
This rewrite in Perl is somewhat less sophisticated and lacks some options of the original, but adds others and does without spurious restrictions. The removed options / features are:
The new features are:
The latter is very useful when processing columns of numbers for scientific computing.
It is installed manually by copying to someplace in your PATH or using the install program. The manual page can be generated with the pod2man program that comes with Perl.
fmt.pl - plain text paragraph and column formatter
fmt.pl [ -s ] [ -u ] [ -w chars | -W words ] [ file ... ]
fmt.pl
is a plain text document formatter similar to the standard fmt
program but at the same time simpler and more versatile. It does without the fancier features of fmt
but is more predictable and configurable in its operation.
Lines are broken at white space, and paragraphs are separated by empty lines containing only white space. Leading empty lines and indentation are always removed. Overlong lines without white space remain unbroken.
If no input file is given, standard input is read.
Command-line options:
Split lines only, never concatenate. In effect, this starts a new paragraph after every line (but does not insert new empty lines).
Make inter-word space uniform: one space between words, two after sentences, and sequences of empty lines are replaced by one. With -W, two tabs are placed between words / columns.
Set maximum line length to width characters. If a word is longer than width characters, the line length will still be exceeded. A width of 0 sets an unlimited line length, causing concatenation of whole paragraphs and no line splitting. The default is 75.
Enables formatting into columns and sets the number of columns. The last option on the command line that is either -w or -W takes precedence.
Copyright 2015 Volker Schatz. May be copied and/or modified according the Gnu General Public Licence version 3 or later (see http://www.gnu.org/licenses/gpl.html).