I have following command to clear last entry of bash history(terminal history/command-line history). My Ubuntu 14.04 Trusty Tahr.
sed -i '$d' ~/.bash_history But I want to keep last 1,2...n entries and delete the rest, how can I achieve that ?
Can be with sed/history/awk or any other command, no problem as far as the requirements are met.
sed -i '1,10!d' ~/.bash_historyreplace 10 with whatever you want to count up to.