Save history for a specific command elsewhere than .bash_history

117 views Asked by At

By default, command history is stored in ~/.bash_history file.

I want to save the history for a specific command elsewhere than ~/.bash_history every time the command is called, like in a file ~/.specific-command-history.

I don't want to run grep to search for a specific command neither exclude it from ~/.bash_history, I just wanted to have a history for a specific command to be automatically stored in other file as well as in ~/.bash_history.

Any thoughts about that?

1

There are 1 answers

0
Shaqil Ismail On

You could create and run an anacron script, even if at a set time the server was switched off, when the server is switched on, anacron will run the script.

The anacron script would grep the file with the command you are looking for, and then use cut, and then append the file you would like to paste the lines into.