[求助]Fmt
Fmt
Unix 的 fmt 程序可以对文本中的段落进行重排,保证每一行不超过 72 个字符。重排时它会遵守以下规则:
-
新的一行可以从任何一个有空格的地方开始。如果开始一个新行,则在上一行的末尾和新行的开始都不应该有任何空格。
-
在输出时,可以删除段落中的换行。文章的段落是通过一个空白行来划分的。
-
在行尾不应该有任何空格。
-
如果在一长串的字符间没有空格,且其长度超过了 72 个字符,则应该把它们放在一个单独的行上。
新的一行可以从任何一个有空格的地方开始。如果开始一个新行,则在上一行的末尾和新行的开始都不应该有任何空格。
在输出时,可以删除段落中的换行。文章的段落是通过一个空白行来划分的。
在行尾不应该有任何空格。
如果在一长串的字符间没有空格,且其长度超过了 72 个字符,则应该把它们放在一个单独的行上。
Sample Input
Unix fmt
The unix fmt program reads lines of text, combining
and breaking lines so as to create an
output file with lines as close to without exceeding
72 characters long as possible. The rules for combining and breaking
lines are as follows.
1. A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the
end of the previous line or at the beginning of the new line.
2. A line break in the input may be eliminated in the output, provided
it is not followed by a space or another line break. If a line
break is eliminated, it is replaced by a space.
Sample Output
Unix fmt
The unix fmt program reads lines of text, combining and breaking lines
so as to create an output file with lines as close to without exceeding
72 characters long as possible. The rules for combining and breaking
lines are as follows.
1. A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the end of
the previous line or at the beginning of the new line.
2. A line break in the input may be eliminated in the output,
provided it is not followed by a space or another line break. If a line
break is eliminated, it is replaced by a space.
Source
Miguel Revilla 2002-06-15[此贴子已经被作者于2006-12-10 12:33:32编辑过]