HISTTIMEFORMAT
If this variable is set and not null, its value is used as a format string for strftime(3) to print the
time stamp associated with each history entry displayed by the history builtin. If this variable is
set, time stamps are written to the history file so they may be preserved across shell sessions.
该变量可以自定义history是的输出显示,格式同strftime,可以根据date命令的格式进行设置
[11:20:14 talen@BJB0300 ~ ]$ export HISTTIMEFORMAT="`whoami`_%F %T : "
[11:20:14 talen@BJB0300 ~ ]$ history
17811 talen_2012-05-29 11:17:14 : export HISTTIMEFORMAT="`whoami`_%F %T : "
17812 talen_2012-05-29 11:17:16 : history
把export HISTTIMEFORMAT="`whoami`_%F %T : "写入到~/.bash_profile中
清除历史记录:
如果历史命令中有敏感信息,不希望别人看到自己的历史记录可以设置HISTSIZE=0,HISTFILESIZE=0,也可以把~/.bash_history 链接为/dev/null
[14:17:15 talen@BJB0300 ~ ]$ ln -s /dev/null ~/.bash_history
还可以手工清除,使用
[14:17:15 talen@BJB0300 ~ ]$ history -c
或者
[14:17:15 talen@BJB0300 ~ ]$ > .bash_history
当打开多个终端时,bash的操作历史并不是立即写入.bash_history文件中的,可以手工写入
[14:17:15 talen@BJB0300 ~ ]$ history -w
阅读(5283) | 评论(0) | 转发(0) |