Let's say I've typed something into the terminal:

Joeterm$egrep " [1-9] " resultsAugmented.txt | egrep -o "20..-..-.." | sort | uniq| grep -c 2010

…but I've not pressed enter yet - I suddenly rememeber that I can't run the command until I first do something else - what are the fastest ways to

  1. blank the prompt without executing the command (I mean, I could leave something heavy on backspace and go and make a cup of tea, but that's not all that efficient)?
  2. Save the command I've typed for later recall, before I then do 1.

I'm looking for least keystrokes ideally…

  • I would simply open another terminal window/tab, honestly. – mkaito Apr 4 '12 at 1:23

CtrlU, the default stty kill key, works pretty much everywhere in Unix terminals.

In bash, it will also put the deleted text in the "kill ring", to be inserted later with CtrlY. This does not persist between sessions, however.


<Ctrl-a>#<Enter> to go to beginning of the line, comment it and "run" it. It will be saved in your shell's history.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.