Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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. Approx something like this:

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


obviously embellish with dates, times, whatever...

share|improve this answer
Nice, concise :) – tink Mar 26 '13 at 22:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.