我构建了我的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