ArticleDirectory
- Parameters
- Option
- Example
Simple Text Formatting
FMT [Option] [File-list]
FMT performs simple text formatting by setting the length of all non-blank rows to almost the same
Parameters
FMTSlaveFile-listAnd the formatted version of the content is sent to the standard output. If you do not specify a file name or use a hyphen(-)To replace the file name, FMT reads text information from the standard input.
Option
-S: truncates long rows but does not merge them.
-T indented except the first line of each paragraph
-U changes the format so that there is a space between words and two spaces between sentences.
-W n: Change the output line width to n characters. Without this option, the FMT output line width is 75 characters
Example
Original file
$CatDemoLong TimeAgo, there was a huge apple tree. A little boy loved to come and play around it every day. He climbed to the tree top, ate the apples, took a nap under the shadow... He loved the tree and the tree loved to play with him.
FMT-S
$FMT-S demoLong TimeAgo, there was a huge apple tree. A little boy lovedto come and play around it every day. He climbed to the tree top, atethe apples, took a nap under the shadow... He loved the tree and Thetree loved to play with him.
Truncation of long rows
FMT-T
$FMT-T demoLong TimeAgo, there was a huge apple tree. A little boy loved to come and play around it every day. He climbed to the tree top, ate the apples, took a nap under the shadow... He loved the tree and the tree loved to play with him.
Exclude indentation of the first line
FMT-u
$FMT-U demoLong TimeAgo, there was a huge apple tree. A little boy loved to comeand play around it every day. He climbed to the tree top, ate the apples, took a nap under the shadow... He loved the tree and the tree loved toplay with him.
The interval between formatting words and sentences. Obviously, multiple spaces in a little boy are truncated to two
FMT-W
$FMT-W 40DemoLong TimeAgo, there was a hugeapple tree. A little boyloved to come and play around itevery day. He climbed to the tree top, ate the apples, took a nap under theshadow... He loved the tree and Thetree loved to play with him.
Specify the output line width. The line width here is 40 characters long and I have never counted it.