1
如何導致ctrlu來自bash腳本?從bash腳本清除當前行上的所有文本
即我想刪除就行光標左邊的所有字符,並把光標在列0
一種解決方法可以打印\r
,其次是一些以清除光標的權利。
我不想清除整個終端屏幕。
更新:
我(在PHP)使用的解決方案:
echo 'mydata' . "\033[0K\r";
如何導致ctrlu來自bash腳本?從bash腳本清除當前行上的所有文本
即我想刪除就行光標左邊的所有字符,並把光標在列0
一種解決方法可以打印\r
,其次是一些以清除光標的權利。
我不想清除整個終端屏幕。
更新:
我(在PHP)使用的解決方案:
echo 'mydata' . "\033[0K\r";
基本上你可以做這樣的事情:
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
使用man tput
獲取更多信息。要查看能力列表使用man terminfo
我在這裏找到了一個工作答案:http://stackoverflow.com/a/5861713/129202所以我想我可以刪除我的問題作爲重複:-P – Jonny
可能重複[bash腳本,擦除前一行?](http://stackoverflow.com/questions/5861428/bash-script-erase-previous-line) – Jonny