红联Linux门户
Linux帮助

在history命令中显示时间

发布时间:2008-07-02 00:21:14来源:红联作者:Osllgre
FreeBSD 6.1上的csh,默认就是开启了这个功能的。

Linux上的BASH默认没有开启这个功能,开启办法是:设置环境变量HISTTIMEFORMAT,设备方法参照strftime的格式(man 3 strftime查看详细信息)。不过这个功能只有在BASH3.0以上的版本中才能使用。原文是这么写的:

New HISTTIMEFORMAT variable; value is a format string to pass to strftime(3). If set and not null, the `history’ builtin prints out timestamp information according to the specified format when displaying history entries. If set, bash tells the history library to write out timestamp information when the history file is written.

比如,在~/.bash_profile里添加如下一行:

export HISTTIMEFORMAT=”%F %T “

然后再使用history的时候,就会显示时间信息了。
文章评论

共有 0 条评论