0

I have this program that restrict the area in input file where is a table and print the number from it. Some of them after an arithmeric operation. I use this program for several files.

BEGIN { CONVFMT="%0.17f" }
/D Format/ { in_f_format=0; next }
/F Format/ { in_f_format=1; next }
in_f_format != 1 { next }
!($1 ~ /^[1-9]/) { next }
$1 == 11 { prt(180,3.141592653589); next }
$1 == 15 { prt(100,1); next }
$1 == 20 { prt(10,1); next }
$1 == 26 { next }
{ prt(1,1) }

function prt(mult, div) {
print trunc($5 * mult / div) ORS trunc($6 * mult / div)
}

function trunc(n, s) {
s=index(n,".")
return (s ? substr(n,1,s+6) : n)
}

So I write

awk -f program.awk input??.txt > output

and I get a column of numbers from all files. Is it possible I get more columns, I mean one column from one file? Thank you

I have input file1:

                      Input-Output in F Format

No.  Curve    Input Param.        Correction     Output Param.    Standard Deviation
26      0  56289.1246870000     -0.0005061178  56289.1241808822      0.0012471332
35      1      0.2201000000      0.0006011114      0.2207011114      0.0002586201
35      2      0.2193000000      0.0006195591      0.2199195591      0.0002380170
35      3      0.2210000000      0.0005884910      0.2215884910      0.0003098441
35      4      0.2196000000     -0.0027586643      0.2168413357      0.0001745397
35      5      0.2186000000      0.0016105429      0.2202105429      0.0004368731
35      6      0.2257000000      0.0077345656      0.2334345656      0.0012506282
35      7      0.2209000000     -0.0000044351      0.2208955649      0.0008990331
35      8      0.2112000000      0.0000913711      0.2112913711      0.0018160767


                      Input-Output in D Format

and input file2:

                      Input-Output in F Format

No.  Curve    Input Param.        Correction     Output Param.    Standard Deviation
 9      0     39.1391000000      0.1608047780     39.2999047780      0.6803853635
11      0      2.7484760000      0.0165707420      2.7650467420      0.0156115006
15      0      0.2212000000     -0.0003215801      0.2208784199      0.0128582929
16      0     80.7925356667     -1.4577069901     79.3348286765      0.1840479039
20      0      2.3163000000     -0.0200039621      2.2962960379      0.0170402504
23      0      4.0020100000      0.0191413168      4.0211513168      0.0136079710
24      0      8.3993500000      0.0189869075      8.4183369075      0.0323801135
26      0  56289.1141540000     -0.0026432978  56289.1115107022      0.0012385980
35      1      0.2275000000     -0.0005258410      0.2269741590      0.0003254581
35      2      0.2286000000     -0.0004090407      0.2281909593      0.0003178654
35      3      0.2296000000     -0.0003626760      0.2292373240      0.0003380276
35      4      0.2247000000      0.0026600182      0.2273600182      0.0003067233
35      5      0.2369000000      0.0004565594      0.2373565594      0.0003858194
35      6      0.2736000000      0.0057719235      0.2793719235      0.0008400692
35      7      0.2285000000     -0.0013381191      0.2271618809      0.0006135248
35      8      0.2178000000     -0.0017247826      0.2160752174      0.0011717965

The output is:

0.220701
0.000258
0.219919
0.000238
0.221588
0.000309
0.216841
0.000174
0.220210
0.000436
0.233434
0.001250
0.220895
0.000899
0.211291
0.001816
39.299904
0.680385
158.425508
0.894473
22.087841
1.285829
79.334828
0.184047
22.962960
0.170402
4.021151
0.013607
8.418336
0.032380
0.226974
0.000325
0.228190
0.000317
0.229237
0.000338
0.227360
0.000306
0.237356
0.000385
0.279371
0.000840
0.227161
0.000613
0.216075
0.001171

The desired output:

0.220701    39.299904
0.000258    0.680385
0.219919    158.425508
0.000238    0.894473
0.221588    22.087841
0.000309    1.285829
0.216841    79.334828
0.000174    0.184047
0.220210    22.962960
0.000436    0.170402
0.233434    4.021151
0.001250    0.013607
0.220895    8.418336
0.000899    0.032380
0.211291    0.226974
0.001816    0.000325
            0.228190
            0.000317
            0.229237
            0.000338
            0.227360
            0.000306
            0.237356
            0.000385
            0.279371
            0.000840
            0.227161
            0.000613
            0.216075
            0.001171

I would like to have output from one input in one columns.

  • It's unclear what you want to do. Could you show a sample of input and what you'd expect to get as output for that sample, along with what you're actually getting? – Kusalananda Mar 24 at 8:01
  • I a, sorry I editted my question – Lukáš Altman Mar 24 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.