Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$ cat test.sh #!/bin/bash sc=$(tput sc) rc=$(tput rc) printf "$sc%s\n" "Type word" read -r word printf "$rc%s\n" "Type word (again)" read -r word_confirmation $ ./test.sh Type word (again) test
我想test被清除。
test
tput ed将屏幕从当前光标位置清除到屏幕末尾(在 macOS 上中断,请参阅此答案)。
tput ed
#!/bin/bash tput sc printf "%s\n" "Type word" read -r word tput rc tput ed printf "%s\n" "Type word (again)" read -r word_confirmation
tput清屏