我将此代码置于无限循环中:
read -a output
echo ${output[@]}
当代码运行时,屏幕可能如下所示:
Hello, World # line where value was given to output (I want this gone)
Hello, World # echoed output
[] # <-- cursor waiting for next input
有没有办法清除用户输入值的行?就像完全摆脱它一样(不仅仅是将线条改为空白,仍然会在所需的输出中留下间隙)?
答案 0 :(得分:2)
将tput
与cuu1
和dl1
功能结合使用。
echo "foobar42"
echo "$(tput cuu1)$(tput dl1)baz123"
答案 1 :(得分:0)
为什么不删除echo ${output[@]}
?由于您没有引用数组变量,这似乎与您使用tput
hax的结果相同。