2008-07-1
在history命令中显示时间
作者:花开 发布时间: 2008-07-1 | 版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处、作者信息及本声名。
本文链接: http://www.bsdmap.com/2008/07/01/history-time/
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的时候,就会显示时间信息了。
On this day..
- 对缓存的新认识 - 2008