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.

I tried to set timestamp for history. My first attempt was do export EXTENDED_HISTORY=ON command, and it seems like doesn't work. Then i do echo 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> /etc/bash.bashrc command, and it works.

After i enabled the timestamp, i do . /etc/bash.bashrc to reload it, then i do history to show my history with timestamp.

But the weird thing i noticed was how does the history can store the timestamp before i enable it?

The first part of my history, all commands have the same timestamp 20:43:04: enter image description here

The second part, start from 619th command, the commands have save their own timestamp, but at this moment, i never enable the history timestamp yet.

enter image description here

Instead, i enable the history timestamp at 694th command:

enter image description here

My $HISTSIZE is set long time ago which was 1000 lines. I using Konsole 2.10.5 terminal and Ubuntu 13.04.

I have no idea the cache is a feature from Konsole or bash.

My question is, how and where does history store the timestamp before i do 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> /etc/bash.bashrc`?

And it seems like have limitation because not all previous history timestamp is store(i.e. 1st to 618th command share the same timestamp). May be it's because of 619th command is the first command for this konsole tab session, i don't remember.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Bash always remembers timestamps, the HISTTIMEFORMAT variable merely determines what gets written to ~/.bash_history. So for commands bash reads from its history file, it only knows the timestamps if they have been written to it, but it always knows its "own" timestamps.

share|improve this answer

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.