有没有方法来黑进bash,拦截并保存它执行的每个命令的输出结果?
我仔细考虑了一下,最简单的形式就是这样:
$ cat clone
#! /bin/bash
bash -i |tee >(cat >>/tmp/bash.log.$$)
# $ vim clone
# Vim: Warning: Output is not to a terminal
$ ./clone
$ du -sb /tmp/bash.log.9609
29 /tmp/bash.log.9609
109 /tmp/bash.log.9609
161 /tmp/bash.log.9609
213 /tmp/bash.log.9609
tee >(cat >>/tmp/bash.log.$$)
?tee -a /tmp/bash.log.$$
不是也能达到同样的效果吗? - holgero