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


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 »


Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit