tput用法
1. Clear all text on current line from a bash script
while :; do # an infinite loop just for demonstration echo "$RANDOM" # print your stuff here sleep 0.2 tput cuu1 # move cursor up by one line tput el # clear the line done
2. save and store cursor
echo "this is a tput test" echo "" tput sc for((i=0,j=7; i<=7; i++,j--)); do ans=$((((((i % 2)) + 1))*2)) echo $(tput cuu1; tput el; tput setaf $ans;)"show me the money $ans"$(tput sgr0) sleep 1 done tput rc echo "test done"
shell tput clear the current line
bash: clear string between two positions - Unix Stack Exchange
shell tput get current cursor position
How to get the cursor position in bash?
tput
: Portable Terminal Control