如何将程序的输出存储到文件中?

时间:2015-04-06 14:40:37

标签: linux file unix stdout

    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Απρ201505:13:12μμEEST“”“这样的额外线条。

1 个答案:

答案 0 :(得分:1)

运行您的程序,如:

$ ./testU01 | tee testU01.out

会在stdout上显示您的程序输出,但也会将其存储到文件testU01.out中。


查看man 1 tee了解详情。