2012-08-14 346 views
4

有誰知道一種方法來破解bash攔截並保存它執行的每個命令的輸出嗎?保存命令輸出到bash歷史

+0

如何慶典| tee bash.out – 2012-08-14 01:30:52

+1

或'man script'。 – tripleee 2012-08-14 04:03:21

+0

它會讓你的歷史快速增長。 – 2012-08-14 06:17:00

回答

0

我給了一些這方面的思想,以最簡單的形式,你有這樣的:

$ 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 
+0

http://www.linuxjournal.com/content/bash-redirections-using-exec – 2012-09-22 19:38:02

+0

爲什麼'tee>(貓>>/tmp/bash.log。$$)'? 'tee -a /tmp/bash.log。$$'會不會這樣做? – holgero 2012-12-17 15:30:19

+0

因爲我習慣了那種語法。我想你是對的。 – 2012-12-17 18:47:19