小编mar*_*arc的帖子

录制 bash 会话

出于审计和文档目的,我想找到一个命令,以便将给定 bash 会话中发生的所有事情都写入文件。

即,我想最终得到一个文件,该文件显示我运行的所有命令以及这些命令的所有输出。

我知道我可以使用历史文件(命令运行)获得一部分,通过重定向输出获得一部分。

但是,我觉得bash本身应该有这种能力,只是我没有找到。

例子:

> bash --some-kind-of-magic output.txt
$ cat file1.txt
this is the content of file1.txt
$ grep test file2.txt
this is the output of the command
$ exit
> cat output.txt
$ cat file1.txt
this is the content of file1.txt
$ grep test file2.txt
this is the output of the command
$ exit
Run Code Online (Sandbox Code Playgroud)

linux bash command-line logging

2
推荐指数
1
解决办法
1532
查看次数

标签 统计

bash ×1

command-line ×1

linux ×1

logging ×1