Sample Header Ad - 728x90

Delete last N lines from bash history

74 votes
14 answers
155407 views
When accidentally pasting a file into the shell it puts a ton of ugly nonsense entries in the bash history. Is there a clean way to remove those entries? Obviously I could close the shell and edit the .bash_history file manually but maybe there's some kind of API available to modify the history of the current shell?
Asked by ThiefMaster (2407 rep)
Feb 17, 2013, 12:40 PM
Last activity: Jul 15, 2025, 09:15 PM