Previous post:

Next post:

Hack 50. Display TIMESTAMP in history using HISTTIMEFORMAT

by Ramesh

Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timestamp along with the command as shown below.

# export HISTTIMEFORMAT=’%F %T ‘

# history | more
       1  2008-08-05 19:02:39 service network restart
       2  2008-08-05 19:02:39 exit
       3  2008-08-05 19:02:39 id
       4  2008-08-05 19:02:39 cat /etc/redhat-release

Note: You can also setup the following alias to view the recent history commands.

alias h1='history 10'
alias h2='history 20'
alias h3='history 30'
Vim 101 Hacks Book

Previous post:

Next post:

{ 1 comment… read it below or add one }

1 Шляпа January 14, 2010 at 7:28 pm

you mean
# export HISTTIMEFORMAT=’%F %T ‘

Leave a Comment

Previous post:

Next post: