免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1223 | 回复: 0
打印 上一主题 下一主题

LINUX下如何查看命令历史及输入时间(抄自CU) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-20 13:25 |只看该作者 |倒序浏览
感觉有点意思,有空再看看。因为有点零散(主要是三人),所以改转载为抄自。

No.1
export PROMPT_COMMAND='{
date "+: %c; `history 1 | { read x cmd; echo "$cmd"; }`";
} >;>; $HOME/.history-timestamp'
或者安装 Bash 3.0
http://ftp.gnu.org/gnu/bash/bash-3.0.tar.gz
bb. 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.
或者用Snare for Linux大炮打苍蝇

No.2
试了有个楼主给的PROMPT_COMMAND,总是有问题。自己就写了个麻烦点的。

把他们加到.bashrc文件中, source .bashrc 即可。
# === Begin ====
datestamp_history(){
export infodate=`date "+: %c"`
export infohis=`history 1`
echo $infodate' =>; '$infohis >;>; $HOME/.history-timestamp
}
export PROMPT_COMMAND=datestamp_history
# === end =====

No.3
export PROMPT_COMMAND='{ z=$(history 1 | { read x y; echo $y; }); echo -n $(date "+%c") :: $z ::; who am i; } >> $HOME/.history-timestamp'



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10295/showart_261850.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP