给定一个需要以有限的文本宽度显示的长字符串,* nix中是否有一个命令行工具可将单行字符串转换为多行字符串,且每行的长度不超过给定的文本宽度?
例如,给定以下字符串
$ MYSTRING="Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world."
我想这样格式化:
$ echo $MYSTRING | special-format-command --width=30
Call me Ishmael. Some years ag
o - never mind how long precis
ely - having little or no mone
y in my purse, and nothing par
ticular to interest me on shor
e, I thought I would sail abou
t a little and see the watery
part of the world.
echo $MYSTRING | fold -w 30
,因为-30
语法没有出现在折叠手册页中?