How does one clear user input in Bash when using 'read'?
I have this code in an infinite loop:
read -a output
echo ${output[@]}
When the code runs the screen might look like this:
Hello, World # line where value was given to output开发者_运维技巧 (I want this gone)
Hello, World # echoed output
[] # <-- cursor waiting for next input
Is there a way to clear the line where the user inputs the value? Like, as in get rid of it totally (not just changing the line to whitespace that will still leave a gap in the desired output)?
Use tput
with the cuu1
and dl1
capabilities.
echo "foobar42"
echo "$(tput cuu1)$(tput dl1)baz123"
Why not just remove the echo ${output[@]}
? Since you're not quoting your array variable, this seems to be the same result as if you were to use tput
hax.
精彩评论