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
I use this (I have bash 4):
histrm() {
local num=${1:- 1}
builtin history -d $(builtin history | sed -rn '$s/^[^[:digit:]]+([[:digit:]]+)[^[:digit:]].*$/\1/p')
(( num-- )) && $FUNCNAME $num
builtin history -w
}
The builtin history parts as well as the last -w is because I have in place a variation of the famous tricks to share history across terminals and this function would break without those parts. They ensure a call to the real bash history builtin (and not to my own wrapper around it), and to write the history to HISTFILE right after the entries were removed.
However this will work as it is with "normal" history configurations.
You should call it with the number of last entries you want to remove, for example:
histrm 10
Will remove the last 10 entries.