Hi All,
in bash I have a text file which is something like
7.96634E-07 1.0000 0.00000E+00 0.0000 0.00000E+00 0.0000 1.59327E-06 0.7071
2.23058E-05 0.1890 6.61207E-05 0.1098 1.13919E-04 0.0865 1.47377E-04 0.0747
....
....
0.00000E+00 0.0000 0.00000E+00 0.0000 0.00000E+00 0.0000 0.00000E+00 0.0000
1.01890E-03 0.0291 3.20088E-03 0.0172 5.45217E-03 0.0134 8.06035E-03 0.0111
Is there a way to read sequentially the data an put them in two columns. In the previous case it would be.
7.96634E-07 1.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.59327E-06 0.7071
2.23058E-05 0.1890
6.61207E-05 0.1098
1.13919E-04 0.0865
1.47377E-04 0.0747
....
....
Thank you,
Sarah
sed 's/[ ]\{3\}/\n/g' input_file
I have the input file with the following contents
7.96634E-07 1.0000 0.00000E+00 0.0000 0.00000E+00 0.0000 1.59327E-06 0.7071
2.23058E-05 0.1890 6.61207E-05 0.1098 1.13919E-04 0.0865 1.47377E-04 0.0747
0.00000E+00 0.0000 0.00000E+00 0.0000 0.00000E+00 0.0000 0.00000E+00 0.0000
1.01890E-03 0.0291 3.20088E-03 0.0172 5.45217E-03 0.0134 8.06035E-03 0.0111
When I am executing the above command I got the output as follows
7.96634E-07 1.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.59327E-06 0.7071
2.23058E-05 0.1890
6.61207E-05 0.1098
1.13919E-04 0.0865
1.47377E-04 0.0747
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.01890E-03 0.0291
3.20088E-03 0.0172
5.45217E-03 0.0134
8.06035E-03 0.0111
Nila
3
Try this,
sed -re "s/[ ]{2,}/\n/g" test_file
Thank you, it works fine except that some times I have two \n probably because there is a new line in the original file.
Anyway to overcome this?
---------- Post updated at 03:14 AM ---------- Previous update was at 03:13 AM ----------
It doesn't seems to work. The output is the same as the input. Thank you anyway,
Nila
5
Try this,
sed -re "/^$/d; s/[ ]{2,}/\n/g" test_file
The solution if scrutinizer does the job, not yet the one of Nila, but I found a solution. Thank you all,