I have some data in this form (3 columns) stored in the variable ABC
:
d1 d2 d3
d4 d5 d6
d7 d8 d9
d10
and I would like to format it in this form (4 columns):
d1 d2 d3 d4
d5 d6 d7 d8
d9 d10
I've tried something like this:
printf "%8.3e %8.3e %8.3e %8.3e\n" "${ABC}"
but it doesn't work. Can anyone see where the problem is?
So you have a file with a content like this:
and you want to convert it into
That is, convert it from 3 columns per line into 4.
For this you can use
xargs
like:Or, if the data is in a variable:
From
man xargs
Test