我想要求用戶輸入幾行文本,它可以通過任何方式將其存儲爲一個變量,我可以稍後調用它。我不想創建多個讀命令,只需要一個可以保存多個段落的命令。雖然讀取存儲沒有空格的每個用戶條目
我嘗試這樣做:
echo "Enter your your paragraph:"
read -d '' -n 1 message
while read -d '' -n 1 -t 2 c
do
message+=$c
done
echo ""
echo "$message"
輸出始終置於一個文本行沒有空格或任何東西。它應該是這樣的,當我運行的代碼,並輸入幾行代碼:
Enter your broadcast message (When done, wait 2 seconds):
This is supposed to be a sentence.
And so is this.
Thisissupposedtobeasentence.Andsoisthis.
應該輸出在sperate線,並與空間兩句話包含在內。