I would like to delete all history entries matching a certain string. I found this method:
grep -v searchstring "$HISTFILE" > /tmp/history mv /tmp/history "$HISTFILE"
but it does not account for the HISTTIMEFORMAT comments, for example:
#1517681911 echo 1 #1517681918 echo 2 #1517681931 echo 3
If I wanted to remove "echo 2", the preceding comment would need to be removed as well. How can I do this?