【问题标题】:Devise script command utility with one simple line command使用一个简单的行命令设计脚本命令实用程序
【发布时间】:2011-09-07 10:03:15
【问题描述】:

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 重定向来复制此行为。 解决方案必须是单行命令(可能包括流水线命令)。

任何帮助都会很棒,比如如果有人能告诉我们如何在所有数据仍在终端上的情况下将标准输入、标准输出和标准错误重定向到某个文件。

【问题讨论】:

    标签: shell stdout stdin stderr


    【解决方案1】:
    $tee -a typescript | sh -i 2>&1 | tee -a typescript
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多