Changing matrices into single lines of data

sedtext processing

I have multiple matrices in a .txt file and I need each matrix to be in a single line. For example,
matrices.txt:

1 2 3 4
2 3 4 5
3 4 5 6

3 4 5 6
2 3 2 5
2 3 4 5
2 3 5 6
2 3 4 5
...

What I would like is modified_matrices.txt:

1 2 3 4 2 3 4 5 3 4 5 6
3 4 5 6 2 3 2 5 2 3 4 5 2 3 5 6 2 3 4 5
...

There are about 1000 matrices in the file and they are not all integers (0.8888888889888).

Best Answer

Possible awk solution could be:

awk 'BEGIN { RS = ""; } { $1 = $1; } 1' matrices.txt > modified_matrices.txt
Related Question