Puddinq.com sharing knowledge

Remove line from command line history

Remove line from command line history

The cli keeps all commands you type and you can access that history. Other people using the same username can also see all those commands.. sometimes it is necessary to remove something.. here are two solutions

$ grep -v searchstring "$HISTFILE" > /tmp/history
$ mv /tmp/history "$HISTFILE"

Another way is with sed:

$ sed -i '/searchstring/d' "$HISTFILE"