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