用法
$ script -h
Usage:
script [options] [file]
Options:
-a, –append append the output
-c, –command run command rather than interactive shell
-r, –return return exit code of the child process
-f, –flush run flush after each write
–force use output file even when it is a link
-q, –quiet be quiet
-t, –timing[=] output timing data to stderr (or to FILE)
-V, –version output version information and exit
-h, –help display this help and exit
-a 选项 ,在现有输出录制的文件的内容上追加新的内容
-c选项 ,后面可以加上需要执行的命令,而不是交互式shell上执行的命令
-r选项 , 子进程中返回退出代码
-f选项 , 如果需要在输出到日志文件的同时,也可以查看日志文件的内容,可以使用 -f 参数。PS:可以用于教学,两个命令行接-f可以实时演示
-q选项 ,可以使script命令以静默模式运行
-t选项,指明输出录制的时间数据
-V选项,输出script的版本信息,然后退出
-h选项,输出script的help信息,然后退出
例子
直接使用
$ script
Script started, file is typescript
不使用任何参数,终端内容将会保存到默认文件 typescript 中
退出
$ exit
exit
Script done, file is typescript
指定保存的文件名
$ script log.txt
Script started, file is log.txt