Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to break one column into multiple columns in Linux [duplicate]

I want to break a column into different rows. e.g.,

test.dat
1
4
3
4
6
2
4
6
8

What I want is to break it into a 3 x 3 matrix

out.dat
1   4   4
4   6   6
3   2   8
like image 535
Kay Avatar asked Sep 29 '25 09:09

Kay


1 Answers

Try using:

pr -ts" " --columns 3 file_name

It is good and short if you don't want to use awk.

There are other methods too (one I told you, I also learnt it from there):

Convert text file into columns

like image 139
Rakholiya Jenish Avatar answered Oct 02 '25 04:10

Rakholiya Jenish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!