我想洗掉游標后的所有內容;不僅是當前行,還有當前位置之后的每個剩余字符。
例如tput sc; ll; tput rc:
root@test:~# tput sc; ll; tput rc
root@test:~# {CURRENT_CURSOR_POSITION}
drwx------ 5 root root 4096 Feb 23 16:34 ./
drwxr-xr-x 25 root root 4096 Jul 1 2021 ../
-rw------- 1 root root 59 Feb 23 16:34 .bash_history
-rw-r--r-- 1 root root 3106 Dec 5 2019 .bashrc
drwxr-xr-x 3 root root 4096 Feb 8 17:07 .local/
-rw-r--r-- 1 root root 161 Dec 5 2019 .profile
drwxr-xr-x 3 root root 4096 Jun 21 2021 snap/
drwx------ 2 root root 4096 Feb 22 11:56 .ssh/
-rw------- 1 root root 12976 Feb 8 17:07 .viminfo
這會將游標留在第二行,輸出為ll剩余。
我正在尋找一種方法
使用洗掉每一行,
tput el直到它到達保存的位置,所以命令鏈是:tput sc; ll; while_deleting; tput rc。這可能會呼叫tput el每一行,這似乎是多余的,但應該沒問題。回傳保存位置后洗掉所有內容。
我研究了很多答案,例如如何在 shell 中洗掉游標后的所有字符、Bash: delete from cursor until end of line with a keyboard shortcut等等,但所有答案都集中在洗掉當前行,而不是休息。
uj5u.com熱心網友回復:
tput cd
cd清除到顯示結束 (*)
https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html#SEC8
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/432624.html
