2017-07-06 72 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