Quote:
Originally Posted by ashishag
Hi,
I use bash history extensively and there are times when I find that a command is there in bash history when it shouldn't be. Rather than going to .bash_history and delete the line corresponding to the command, is there a way, to delete that command from bash itself. For example, by doing Ctrl-P repeatedly, I move to that command, and then typing Ctrl-u deletes it. But then this remain only for the current session and the change is not permanent, that is, the command hasn't been deleted from the file actually, but only from the history loaded by bash in the memory. I hope I've made myself clear.
I'll be really grateful if someone could answer this question.
|
Your history is in you .bash_history file! From a terminal find your home folder
(mine is /home/mahdiy). If you type “pwd” you will know what folder you are in.
If you see /home/xxxx then type “ls -a” then you will see all of your folders. You will see .bash_history in that list!
Then use a text editor like vi. You would type if using vi: “vi .bash_history”
I used joe instead. I like joe because you (I rather) can move around easier than I can with vi. In joe you can also tell it to jump to line so an so.
So I wrote down the lines I wanted to remove from my history. Went in to a terminal, typed “pwd” to make curtain I was where I wanted to be. You can also type “ls -a” so you see your .bash_history listed your home/xxx directory.
Then type joe (or what ever text editor your are using) .bash_history and you are in.
find the lines you want to remove and remove them.. Save and exit and your done.
There is a joe tutorial on line. You can fool around with the tutorial for a while before you make the plunge:-)
I hope that help:-)