我構建了我的web服務器,並且正在嘗試做一個測試。所以,我與模擬bash腳本許多要求:
bash:如何在同一位置回顯字符串
i=0
while [ $i -lt 20 ]; do
echo ''
echo ''
echo ''
echo '============== current time ==============='
echo $i
echo '==========================================='
echo ''
curl -i http://www.example.com/index?key=abceefgefwe
i=$((i+1))
done
這種運作良好,但我更願意讓所有的echo
在終端上的同一位置。
我讀過這樣的:How to show and update echo on same line
所以我添加-ne
爲echo
,但它似乎並不如預期的工作。
curl
的消息仍然可以將echo
推開。
這就是我需要:
============== current time =============== ---\
1 <------ this number keeps updating ----> the 3 lines stay here
=========================================== ---/
Here is the messages of `curl`, which are showing as normal way
我不知道是否有更簡單的方法來解決這個問題,但'ncurses'庫你可以實現你想要的。 –
@ sid-m好的,謝謝。 – Yves