Search code examples
bashshellunixcommand-linehistory

How to load bash command history from file


I am moving from one server to another, but want to keep my history, so I dumped it into a file.

history > file.txt

Is there a way to overwrite the commands-history of bash and load it from a file?


Solution

  • The following will append the contents of file.txt to the current in-memory history list:

    history -r file.txt
    

    You can optionally run history -c before this to clear the in-memory history.