Artificial intelligent assistant

Clear bash history except last n lines 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.

If you want to keep the last N lines, use `tail` (for example, the last 20 lines):


tail -n 20 "$HISTFILE" > ff && mv ff "$HISTFILE"


I'm using the `HISTFILE` variable since this will always point to your history file, even if you've changed its name.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 71a21b038f9b943f10ed1adfd5751bf0