2

I've got a file that looks like this:

$cat myfile.dat

Number of reps:     nrep=  19230
flop count:         nops=  4725964800.

Clock resolution is  4.7619047619047619E-4 , usecs
time =  7.18247611075639725E-6
calc      0: time=    2.902 Gflop/s=    1.629 error=         0.00000000
calc    201: time=    1.186 Gflop/s=    3.985 error=         0.00000000
Number of reps:     nrep=  13456
flop count:         nops=  4234564800.

Clock resolution is  3.7619047619047619E-4 , usecs
time =  7.18247611075639725E-6
calc      0: time=    1.232 Gflop/s=    2.456  error=         0.00000000
calc    201: time=    3.186 Gflop/s=    1.345  error=         0.00000000

I am interested to filter just what I need :nrep,time and Gflop/s but this last two only of the line starting with calc 201.

So far I've managed to filter what I want, except the elements time and Gflop/s. This is what I've done:

awk -F'= ?' '/nrep=/||/time=/||/Gflop/{print $2}' myfile.dat

19230
2.902 Gflop/s
1.186 Gflop/s
13456
1.232 Gflop/s
3.186 Gflop/s

This is obviosly wrong. What I would need, ideally in columns instead is:

19230 1.186 3.985
13456 3.186 1.345

Is there a reasonbale way of doing that?

4

3 に答える 3

4

GNU awkあなたは単純に次のようにします:

$ awk 'NR>1{print $2,$27,$29}' RS='Number of reps:' file
19230 1.186 3.985
13456 3.186 1.345
于 2013-08-10T16:39:41.540 に答える