0
tput cuu 1 && tput el
適用於多個echo
的情況。但是,如何更換由read
打印的行呢?如何使用輸入覆蓋讀取打印的行
echo "First line..."
read -p "Press any key to overwrite this line... " -n1 -s
tput cuu 1 && tput el
echo "Second line. read replaced."
上述輸出的例子:
First line... Second line. read replaced.
我想的最終結果爲:
First line... Second line. read replaced.
'tput cuu1'將光標向上移動1,但行保持不變。您還需要將光標移動到左側。 – alvits
@alvits不是'tput el'基本上應該消滅整條線? – Luke
編號'el'從當前位置擦除行尾。 – alvits