2017-07-06 109 views
1

我有以下回声字符串:猛砸保持大文本标签

echo "Title" 
echo -e "\t Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book." 

我的输出是:

> [mymachine ~]$ example.sh 
> Title 
>  Lorem Ipsum is simply dummy text of the printing and typesetting 
> industry. Lorem Ipsum has been the industry's standard dummy text ever 
> since the 1500s, when an unknown printer took a galley of type and 
> scrambled it to make a type specimen book. 

正如你在这个例子中,文本串过大和控制台放见它在四行,但只有第一个保存选项卡。

我在寻找这样的输出:

> [mymachine ~]$ example.sh 
> Title 
>  Lorem Ipsum is simply dummy text of the printing and typesetting 
>  industry. Lorem Ipsum has been the industry's standard dummy text 
>  ever since the 1500s, when an unknown printer took a galley of type 
>  and scrambled it to make a type specimen book. 

有没有什么办法,使大量的文本字符串保存选项卡上的控制台每一行?

+0

有你尝试使用'cat'而不是'echo'?你不能设置行长,但你可以直接写出将要显示的内容:'cat << EOT 你的文字有多行和空格EOT' –

回答

5

我怀疑你正在寻找的东西像fmt

echo "Title" 
printf "\tLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.\n" \ 
| fmt 

出人意料的是,GNU FMT(版本8.25)不会兑现$列,所以你可能要使用:

fmt -w ${COLUMNS:-80} 
+0

非常感谢!作为例外工作。 – Steve