It’s often the case that we want to review our command history to look for certain erroneous or useful commands. We can do this using history command or just looking at the contents of ~/.bash_history file. Sometimes that’s not enough, and we want to know the exact time certain command was executed (think of systems with much longer up-times). Well, if we define HISTTIMEFORMAT environment variable our shell starts time-stamping our commands. This variable should be assigned a string that follows time format specification similar to the date command, except for the preceding ‘+’ of course. For example:
export HISTTIMEFORMAT=”%F %T “
The time-stamps would only be reliable for any future commands, as older commands weren’t tracked by the shell. ~/.bash_history file would also look different now, as bash would be inserting a Unix Epoch value before each command.
Here goes a sample screenshot.



Thanks for this useful tip.
However, I’d like to mention that your blog software is breaking your command line by replacing the quote characters (“) with bird droppings… This way, it can’t be used as is (by copy-pasting). Please fix this.
Comment by AK — September 19, 2011 @ 11:46 am