Unable to delete useless commands from ~/.bash_history

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mohittomar13

Mohit Tomar
Thread Starter
Joined
May 2, 2011
Messages
394
I wanted to delete commands that are common (such as pwd, ls -l, cd, ) and keep the ones that I might forget how to use. To do this I ran the following commands

Code:
history | grep "cd$" | cut -c 1-5 > ~/sandboxArea/histDelTemp.txt
cntr=0; for i in $(cat ~/sandboxArea/histDelTemp.txt); do var=`expr $i - $cntr`; history -d $var; cntr=`expr $cntr + 1`; done; unset cntr
And after running the above command when I again run the
history | grep "cd$"
command it seems that everything was deleted. But if I close my terminal and again open it then everything seems to come back like it was before.

Does bash has a mechanism for history backup? Why does the entries reappear? Please help.
Thanks in advance
 

mohittomar13

Mohit Tomar
Thread Starter
Joined
May 2, 2011
Messages
394
But if I do
history -d 6747 (for eg.)
then it does work and nothing reappear
 

mohittomar13

Mohit Tomar
Thread Starter
Joined
May 2, 2011
Messages
394
Found the solution. Actually, after deleting the items we need to run the following:

Code:
history -w
and it's that simple (n)(n)(n)(y)(y)
 

mohittomar13

Mohit Tomar
Thread Starter
Joined
May 2, 2011
Messages
394
I should have written "common" instead of "useless" in the title, as a matter of fact these are the commands that are most used in linux:whistle::whistle::D:D
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top