Linux常用命令-script

命令

script

描述

make typescript of terminal session
记录终端会话操作

用法

1
script [options] [file]

选项

1
2
3
4
5
6
7
8
9
10
Options:
-a, --append 追加到文件
-c, --command <command> 运行命令而非交互式的shell
-e, --return 返回子进程的退出码
-f, --flush 每次写操作后都运行flush
--force 强制输出到文件
-q, --quiet 静默模式
-t[file], --timing[=<file>] 输出时间数据到文件

退出记录使用exit或logout命令,或者使用快捷键ctrl+d

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 开始记录,推荐使用长选项--timing=xxx
$ script --timing=file.tm file.out
Script started, file is file.out
$ ls
$ ll
$ echo aaa > a
$ more a
...
$ exit
exit
Script done, file is file.out
# 回放记录,回放过程中可以按ctrl+c结束
$ scriptreplay -t file.tm file.out
# 2倍速回放
$ scriptreplay -t file.tm file.out 2
# 0.5倍速回放
$ scriptreplay -t file.tm file.out 0.5