This should work because echo is a default command for xargs
xargs -n 3 file
4
votes
Using rs - reshape a data array:
$ cat file | rs -C' ' 2 3
1 2 3
4 5 6
rs reads the standard input
-C output column separator
2 3 rows and columns
Use -t to transpose the input:
$ cat file | rs -C' ' -t 2 3
1 3 5
2 4 6
2
votes
With sed:
sed 'N; N; s/\n/ /g' file
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more