答案1
使用fold
。页面摘录man
:
Wrap input lines in each FILE (standard input by default), writing to
standard output.
-b, --bytes
count bytes rather than columns
-c, --characters
count characters rather than columns
-s, --spaces
break at spaces
-w, --width=WIDTH
use WIDTH columns instead of 80
使用fold
(也许使用该-s
选项,这样它就不会在单词中间断行)将文档设置为大约 80 个字符宽并打印:
fold -s myfile.txt | lpr
或者,保存格式化版本:
fold -s myfile.txt > output.txt