I had previously submitted the same question and PHV did answer, however, the short script of PHV seems not to work.
I have tried with this script, but still not works.
{
for(i=1; i <= NF; i++)
printf ("%10.4e",$i);
}
I am trying to format a large file.
An example input file is below:
0 0 0 0 0.00120833 0.00331665 0.00335832 0.00339165 0.00342499 0.00295832
0 0 0 0 0 0 0.000816663 0.00241666 0.00224999 0.00227499
0.000841663 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
The output file would be like:
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 1.2000e-03 3.3000e-03 3.4000e-03 3.4000e-03 3.4000e-03 3.0000e-03
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 8.0000e-04 2.4000e-03 2.2000e-03 2.3000e-03
8.0000e-04 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
The output file has a fortran format as: 10e12.4
Could someone please help as how to make this format in awk. I am new with awk.
Thanks.
I have tried with this script, but still not works.
{
for(i=1; i <= NF; i++)
printf ("%10.4e",$i);
}
I am trying to format a large file.
An example input file is below:
0 0 0 0 0.00120833 0.00331665 0.00335832 0.00339165 0.00342499 0.00295832
0 0 0 0 0 0 0.000816663 0.00241666 0.00224999 0.00227499
0.000841663 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
The output file would be like:
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 1.2000e-03 3.3000e-03 3.4000e-03 3.4000e-03 3.4000e-03 3.0000e-03
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 8.0000e-04 2.4000e-03 2.2000e-03 2.3000e-03
8.0000e-04 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
The output file has a fortran format as: 10e12.4
Could someone please help as how to make this format in awk. I am new with awk.
Thanks.