For the purposes of looking at which commands I am using the most, I'd like to keep a record of command I type in my bash history (even duplicates).

But, for sanity and ease of use, I still want to keep my ignoredups setting on.

Is there a way to automatically create two history files? With the "default" being no duplicates, and the full history elsewhere?

1 Answer 1


You could ignore the builtin history mechanism and abuse $PROMPT_COMMAND to write history any way you wanted. Some people keep a directory of history files, one for each shell/date/hostname, etc. Approximately something like this:

prompt_cmd() {
    echo "$_" >> $HOME/.my_history_file_$HOSTNAME


obviously embellish with dates, times, whatever...

  • Nice, concise :)
    – tink
    Mar 26, 2013 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .