//View Tip #534
Similar Tips
» Stream shell commands to Twitter
» Up/down arrow keys for searching history
» Fix the previous command
» Disable bash history
» Use history to SUDO last command

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Typically when one types the history command, it displays the command number and the command. For auditing purposes it would be helpful to display the timestamp as well. To do so we need to set the environmental variable HISTTIMEFORMAT.

HISTTIMEFORMAT supports format strings of strftime.

Some important format strings:

%T Replaced by the time ( %H : %M : %S )
%F Equivalent to %Y - %m - %d

$ export HISTTIMEFORMAT='%F %T '

Now execute
$ history

it will print the command line history with corresponding timestamp when the command was executed, such as:
499  2009-02-11 18:20:52 ls


View Comments »




Comments 

Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit