How can I remove a certain line from history's database?
|
|
Just edit the file |
|||||
|
59 is the line number. Cannot be anything sweeter than this :) |
||||
|
|
|
If you need to remove several lines at the same time I normally use this:
If you need to remove the last command you can use:
|
|||
|
|
If you need to remove a range of lines from history, the following bash function could save you some time:
Function should be typically added to
(Note: This question is among the top search results if you search for deleting a range of commands from bash history. So, while the above is more than what the question asks, it could be useful for some readers.) |
|||||
|
|
To prevent a command from being added to the history in the first place, make sure that the environment variable
This will prevent any command with a leading space from being added to the history. You can then clear the history completely by running
|
|||||
|
|
|
Typing "history -d xxx" will delete a specified line. You then have to type "history -w" to make them permanent. It also removes them from the .bash_history file. The surest fire way is cYrus's answer. |
||||
|
|