Sunday, February 24, 2008

history 显示日期

一直以为history命令的输出不会有时间记录,今天看了history的man手册,才知道是自己孤陋寡闻了。
要想让history命令输出带有时期的格式,只需要设置HISTTIMEFORMAT环境变量就可以了,其时间格式描述和date命令是一致的,比如

#export HISTTIMEFORMAT="%F %T "
[root@localhost tools]# history
   1  2007-03-27 11:18:40 rpm -qf /usr/sbin/lvscan
   2  2007-03-27 11:18:40 sl
   3  2007-03-27 11:18:40 ls
   4  2007-03-27 11:18:40 df
   5  2007-03-27 11:18:40 df -h
   6  2007-03-27 11:18:40 cd /tmp

No comments: