shell脚本,录制和回放终端的小工具script。

复制代码
action.log和time.log这两个配置文件被当做script命令的参数。这两个文件可以随便命名。
这里用time.log和action.log。其中time.log用于存储时序信息,描述每一个指令在何时运行;
action.log用于存储命令信息输出。-t选项用于将时序数据导入stderr。2>用于stderr重定向到time.log。
[root@localhost ~]# script -a action.log  -t 2>time.log   
Script started, file is action.log
[root@localhost ~]# who
(unknown) :0           2016-09-05 12:24 (:0)
root     pts/0        2016-09-05 12:25 (192.168.1.79)
root     pts/1        2016-09-05 12:44
[root@localhost ~]# ls 
0          1file.sh        3file.sh    anaconda-ks.cfg              clearlog.sh  fibo.sh  initial-setup-ks.cfg  m2.txt  m4.txt        time.log     yibai.sh    视频  音乐
1          2016815.tar.gz  99.sh       apache-tomcat-7.0.70.tar.gz  copy.sh      file     m1                    m3      show          wenjian      yijiaer.sh  图片  桌面
112233.sh  2file.sh        9file       a.txt                        create50.sh  file.sh  m1.txt                m3.txt  showdiff.sh   wyb          公共        文档
1file      2five.sh        action.log  b.txt                        del50.sh     five.sh  m2                    m4      students.txt  yibaifor.sh  模板        下载
[root@localhost ~]# date
2016年 09月 05日 星期一 12:44:45 CST
[root@localhost ~]# exit           #退出用ctrl+d 或是exit
exit
Script done, file is action.log
[root@localhost ~]# scriptreplay time.log action.log   #敲回车后,就将自动回放你之前输入的操作了。
复制代码

 

posted on   王月波  阅读(1202)  评论(0编辑  收藏  举报

编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示