Delete a command from the history
If I run a command that, maybe shows a password in it, I’d like to delete that command from my command history. Say I this shows when I run history:
494 ping pint 495 ssh pint 496 ssh trust 497 ssh carvo 498 exit 499 host smithfest 500 ssh egg
And say that I want to delete the line “host smithfest” from that list. Do this:
yo:~ $ history -d 499 yo:~ $ history -w yo:~ $ history 494 ping pint 495 ssh pint 496 ssh trust 497 ssh carvo 498 exit 499 ssh egg 500 history 501 history -d 499 502 history -w 503 history
If you don’t run the history -w command, it won’t write the change and the line would still be present if you logged out and back in.