Saturday, January 8, 2011

How do we see shell command history with timestamp under Linux OS?


If the HISTTIMEFORMAT is set, the time stamp information connected with each history entry is written to the history file, marked with the history comment character. We can define below variable to set  timestamp for history command
$ HISTTIMEFORMAT=”%d/%m/%y %T “

OR

echo ‘export HISTTIMEFORMAT=”%d/%m/%y %T “‘ >> ~/.bash_profile
Where,
%d – Day
%m – Month
%y – Year
%T – Time

To see history type
# history