Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer 1

up vote 7 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
}

PROMPT_COMMAND=prompt_cmd

obviously embellish with dates, times, whatever...

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

Your Answer

 
discard

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.