【问题标题】:How to store my program's output into a file?如何将程序的输出存储到文件中?
【发布时间】:2015-04-06 14:40:37
【问题描述】:
    spykoni@spykoni-H81M-S2PV:~/Desktop/C_plus_plus/MIXMAX/mixmax_release_100_beta$ 
    spykoni@spykoni-H81M-S2PV:~/Desktop/C_plus_plus/MIXMAX/mixmax_release_100_beta$ 
    spykoni@spykoni-H81M-S2PV:~/Desktop/C_plus_plus/MIXMAX/mixmax_release_100_beta$ 
    spykoni@spykoni-H81M-S2PV:~/Desktop/C_plus_plus/MIXMAX/mixmax_release_100_beta$ cat screen.log 
    Script started on Δευ 06 Απρ 2015 05:13:12 μμ EEST
    spykoni@spykoni-H81M-S2PV:~/Desktop/C_plus_plus/MIXMAX/mixmax_release_100_beta$ ./testU01 
    Welcome to the MIXMAX random number generator!
    The curent matrix size is 256, with arithmetic  mod 2^61-1
special entry in the matrix is -1
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                     Starting SmallCrush
                     Version: TestU01 1.2.3
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


***********************************************************
    HOST = spykoni-H81M-S2PV, Linux

    float


    smarsa_BirthdaySpacings test:
-----------------------------------------------
       N =  1,  n = 5000000,  r =  0,    d = 1073741824,    t = 2,    p = 1


          Number of cells = d^t = 1152921504606846976
          Lambda = Poisson mean =      27.1051


    ----------------------------------------------------
    Total expected number = N*Lambda      :      27.11
    Total observed number                 :      23
    p-value of test                       :    0.75


    -----------------------------------------------
    CPU time used                    :  00:00:00.97

    Generator state:

我有一个 C++ 程序,我在 Linux 中运行,运行程序后它给了我很多信息作为输出,我想将这些信息保存在文件中以便以后查看所有信息,因为它很大.我可以保存或者说记录 Linux 屏幕上的所有信息。正如我所看到的,有多种方法可以做到这一点,但我只想将信息保存在程序的输出中。在这个例子中,我只想保存从开始 SmallCrush 开始,因为我的程序从那里开始打印信息。我不想要 """ /mixmax_release_100_beta$ cat screen.log 脚本开始于 Δευ 06 Απρ 2015 05:13:12 μμ EEST """ 这样的额外行。

【问题讨论】:

    标签: linux file unix stdout


    【解决方案1】:

    像这样运行你的程序:

    $ ./testU01 | tee testU01.out
    

    将在stdout 上显示程序的输出,同时将其存储到文件testU01.out


    查看man 1 tee了解更多信息。

    【讨论】:

    • 非常感谢,它成功了,我正在尝试但没有结果。而你只是在一秒钟内帮助了我
    • @Narek : Np :) 请注意接受回答您问题的帖子。
    • 对不起,我不明白你,因为我是stackoverflow的新手,你能解释一下你的意思吗?
    猜你喜欢
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多