Search code examples
bashcommand-lineterminalautocompletewindows-subsystem-for-linux

How to delete a single command from history in bash


After some searching online I found that the following command should remove a single entry from the bash history:

$ history -d <number>

So let's say I would like to remove this single line from my history because I misspelled git :

10003 gti add . && git commit -m

When I do the following command:

$ history -d 10003

It still shows up in my history, even when I restart the terminal

So any idea how I can fix this because I use autocomplete and sometimes especially when using git it can get a bit messy.


Solution

  • It's solved by deleting the command from ~/.bash_history