How to delete buffered text written to terminal during script execution
9
votes
3
answers
828
views
Let's say hypothetically I'm executing a long-running bash script, and while it's running, I accidentally right click on the terminal and paste a sensitive password (freshly copied out of a password manager) into the terminal.
~$ process_data.sh
[useful data 1]
[useful data 2]
...
[useful data N-1]
hunter2[useful data N]
[useful data N+1]
**Is there any way to remove the text (hunter2) from showing up on the terminal, while preserving the useful data?** Ctrl-L and clear
delete everything on the screen. Ctrl-H works to delete characters in the current line, but I can't move the cursor up.
I don't need to delete the text from ~/.bash_history
, I just want the useful data to show up in the terminal without the offending text.
I assume the answer may depend on the capabilities/implementation of the terminal. I'm on Ubuntu 18, but solutions for any common terminal would be appreciated.
Asked by Ivoirians
(193 rep)
Apr 23, 2025, 08:29 PM
Last activity: Apr 26, 2025, 06:39 AM
Last activity: Apr 26, 2025, 06:39 AM