Pages

Deleting a command from the history

The history command allows us to look at all the various commands that we have executed in the recent time.
The number of commands remembered at any given time is determined by the environment variable HISTSIZE.
We can use the echo command to see its value



If we want to get rid of some of the unnecessary commands that have been stored in the history (or keep some the commands we have executed a secret ;-) ) we can use the option "-d" with the command history and pass as an argument the command number that has to be deleted.

For eg.



The above is just a snapshot of some of the commands that got listed in the history in my terminal, now if the command "kill -9 -1" has to be removed from the list which has number 496 we can do it by running the command



Now if we run the history command again, the "kill -9 -1" will not be listed and the number 496 will have been assigned to the next command in the list.



No comments:

Post a Comment