I know that Ctrl+R let's you search command history, but it's a little primitive. Is there a way to export all my command history (not just the current terminal session, but the full history) to a text file? I could then use a text editor to search it comfortably. Or if the history file already exists, where is it?
From
man bash
:So, the variable
HISTFILE
will contain the filename where the history will be saved.You can now search for the pattern:
As @Dennis has pointed out, if you want you can run
history -a
to append the command history of the running session to the$HISTFILE
file. Basically the commands will be automatically appended once you close a session,history -a
will do the same thing right at that instant.Run
help history
to get more idea on thehistory
builtin itself.The bash history is saved in your home directory
~/.bash_history
.Basically Ctrl + R searches from this file.
Try this:
Then search by typing
/
+searchterm