Zom*_*ies 2 formatting textfiles
我想简单地获取给定的文本文件并强制最大列长度为 80。我该如何解决这个问题:
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
Run Code Online (Sandbox Code Playgroud)
并将其变成这样:
Four score and seven years ago our fathers brought forth on this continent, a n
ew nation, conceived in Liberty, and dedicated to the proposition that all men
are created equal.
Run Code Online (Sandbox Code Playgroud)
使用折叠命令:
fold -s -w 80 filename
Run Code Online (Sandbox Code Playgroud)
-s如果您更喜欢在字符边界而不是单词边界(实际上是空格)处中断,请忽略该选项。
我怀疑如果文本以多字节编码(例如 UTF-8(并包含非 ASCII 字符))进行编码,这将不会很好地工作。
如果您使用的是 Windows,请使用Cygwin、UnxUtils或GnuWin32 - 它们可能包括折叠。
| 归档时间: |
|
| 查看次数: |
218 次 |
| 最近记录: |