2011-09-07 48 views
0

script工具的工作原理是這樣的:設計腳本命令行工具

$ script 
Script started, file is typescript 
$ ls 
2   bin   doubleline new1  play  typescript 
alok  core  filelist output  pslist  unix 
$ ps 
    PID TTY  TIME CMD 
28149 pts/7 0:00 ksh.ms 
$ 
Script done, file is typescript 

typescript文件的這一內容後爲:

$ cat typescript 
Script started on Wed Sep 07 05:56:26 2011 
$ ls 
2   bin   doubleline new1  play  typescript 
alok  core  filelist output  pslist  unix 
$ ps 
    PID TTY  TIME CMD 
28149 pts/7 0:00 ksh.ms 
$ 

script done on Wed Sep 07 05:56:33 2011 

$ 

我想用複製此行爲其他命令和I/O重定向。 解決方案必須是單行命令(可能包含流水線命令)。

任何幫助都很棒,就像任何人都可以告訴我們如何將stdin,stdout和stderr重定向到某個文件,而所有數據仍在終端上。

回答

0
$tee -a typescript | sh -i 2>&1 | tee -a typescript