Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1783331
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: LINUX

2012-05-29 11:18:14

       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



阅读(5200) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~