------------------------------------------------------------------------
pr (column-> matrix, merge files)
------------------------------------------------------------------------

-n ... here n is a number (number of columns)
-t ... no header, trailer, file name etc
-l ... number of lines in a page (default is 66)
-s ... ouput field separator (by default it is a tab)

------------------------------------------------------------------------
columns -> matrix
------------------------------------------------------------------------

Let us start with a single column
$ seq 9
1
2
3
4
5
6
7
8
9

Say you want to write this column to a matrix with 3 columns. You
do not wish to use the standard "header" and "trailer" etc. So "-t".
Finally, you wish to have OFS=",".

$ pr -3 -t -s, <(seq 9)     
1,4,7
2,5,8
3,6,9

Now, say you want to write "across" (transpose)
$ pr -3 -t -s, -a <(seq 9)   
1,2,3
4,5,6
7,8,9

By default "pr" fills a page of 66 lines and then starts a new page.
So for files longer (in this case), 3*66, we need to set the "l"
parameter to a larger number

$ pr -3 -t -s, -l 1000 <(seq 270)   #will print in one "page"

Let n be the number of lines in the input file and ncol be the
number of columns requested.  The number of rows is set to [n/ncol]+1.
Note that if rem(n,ncol) is not zero then the last column will be
filled list.  In the above case, n=270, ncol=3. Thus nrow=90 which
is <l=1000 and rem(n,ncol)=0.

------------------------------------------------------------------------
merging files
------------------------------------------------------------------------

"pr" can be used to merge two files ("-m")

For this exercise, we will generate a column of alphabets
$ echo {a..d}
a b c d
$ echo {a..d} | xargs -n 1
a
b
c
d

or alternatively 
$ echo {a..d} | gsed 's/ /\n/g'


$ pr -t -m -s, <(seq 4) <(echo {a..d}|xargs -n 1) 
1,a
2,b
3,c
4,d

You can combine more than two files 
or even more files

$ pr -t -m -s, <(seq 4) <(echo {a..d}|xargs -n 1) <(echo {A..D}|gsed 's/ /\n/g')
1,a,A
2,b,B
3,c,C
4,d,D