Often I'll execute a command in bash, press the up arrow to retrieve it from history, edit it, and execute the edit. However, sometimes I'll decide to discard the edit and run a different command or something. This poses a problem because the edited command, which I didn't run, gets saved over top of the original history entry so I can no longer run the original with ease.

For example, here's the end of my current history:

2132* svn cleanup && svn up --set-de
2133  history

The first command was originally svn cleanup && svn up --set-depth=infinity folder1 folder2.

Is there a way to disable overwrites or revert them to the original commands?


1 Answer 1


Abort the line editing with ctrl+c instead of deleting the command, that way bash doesn't overwrite the history line.

  • This works, thanks for the quick response! I usually press up or down to move to another history entry however, rather than backspacing the line clear -- if I'm more than a couple lines up into the history I'll also be annoyed/slowed by Ctrl+C losing my place and needing to tap up again. Jan 28, 2013 at 18:59

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.