shell fold限制文件行宽

 

将文本的行限制到特定的宽

这个用 echo 命令发送的文本用 -w 选项分解成块。

在这个例子中,我们设定了行宽为12个字符。

如果没有字符设置,默认是80。

增加的 -s 选项将让 fold 分解到最后可用的空白 字符,即会考虑单词边界。

 

例子

echo "The quick brown fox jumped over the lazy dog." | fold -w 12

输出

The quick br
own fox jump
ed over the
lazy dog.

 

例子

echo "The quick brown fox jumped over the lazy dog."| fold -w 12 -s

输出

The quick
brown fox
jumped over
the lazy
dog.

 

posted @ 2018-12-14 17:06  anobscureretreat  阅读(410)  评论(0编辑  收藏  举报