Commands follows
511 clear
512 history
513 history -d 505
514 history
515 history -d 507 510 513
516 history
517 history -d 509
518 hist
history -c will clear all histories.
Have you tried editing the history file directly:
~/.bash_history
I used a combination of solutions shared in this thread to erase the trace in commands history. First, I verified where is saved commands history with:
echo $HISTFILE
I edited the history with:
vi <pathToFile>
After that, I flush current session history buffer with:
history -r && exit
Next time you enter to this session, the last command that you will see on command history is the last that you left on pathToFile.
Not directly the requested answer, but maybe the root-cause of the question:
You can also prevent commands from even getting into the history, by prefixing them with a space character:
# This command will be in the history
echo Hello world
# This will not
echo Hello world
to delete last 10 entries (based on your example) :
history -d 511 520
for x in `seq $1 $2`
do
history -d $1
done