regex - Lines with 10 columns to be modified into lines with 3 columns -
i have huge data file containing 10 columns per line. must rearranged such contains 3 columns per line. can sed or awk or perl me? example, following lines
-6.222 -5.809 43.663 3.778 -5.809 43.663 7.784 5.483 -14.013 6.873 5.197 -13.865 5.648 -0.107 -14.156 5.485 -1.058 -14.103 -0.809 7.565 -11.708 -1.157 6.740 -11.343 -0.687 -7.913 -15.833 -0.823 -8.865 -15.733
must become
-6.222 -5.809 43.663 3.778 -5.809 43.663 7.784 5.483 -14.013 6.873 5.197 -13.865 5.648 -0.107 -14.156 5.485 -1.058 -14.103 -0.809 7.565 -11.708 -1.157 6.740 -11.343 -0.687 -7.913 -15.833 -0.823 -8.865 -15.733
i appreciate help. thanks!
an alternate solution using command line utilities tr
, fold
$ tr '\n' ' ' < file | fold -w24 -6.222 -5.809 43.663 3.778 -5.809 43.663 7.784 5.483 -14.013 6.873 5.197 -13.865 5.648 -0.107 -14.156 5.485 -1.058 -14.103 -0.809 7.565 -11.708 -1.157 6.740 -11.343 -0.687 -7.913 -15.833 -0.823 -8.865 -15.733
the replacement of newline space intentional preserve formatting.
Comments
Post a Comment