How to paste properly?

I needed to view calendar for several months so I created a separate file for each and then pasted them like this:

 
cal Dec 2011 > x1; 
cal Jan 2012 > x2;
paste x1 x2
   December 2011            January 2012    
Su Mo Tu We Th Fr Sa    Su Mo Tu We Th Fr Sa
             1  2  3     1  2  3  4  5  6  7
 4  5  6  7  8  9 10     8  9 10 11 12 13 14
11 12 13 14 15 16 17    15 16 17 18 19 20 21
18 19 20 21 22 23 24    22 23 24 25 26 27 28
25 26 27 28 29 30 31    29 30 31  

I think it can be done without creating a temp files, so I tried:

( cal Dec 2011; cal Jan 2012; ) | paste - -

but result is a mess, not what i need.

How do I put my pipes together, so the result is nice and readable as above

Not sure what OS or shell you're using, but try this:

paste -d'\t' <(cal 12 2011) <(cal 1 2012)

Thank you!
It worked under bash and ksh,

the Bourne sh did not understand syntax:

 
$ paste -d'\t' <(cal 12 2011) <(cal 1 2012)
syntax error: `(' unexpected
$ paste -d'\t' <( cal 12 2011 ) <( cal 1 2012 )
syntax error: `(' unexpected

but this is non-issue, I don't have to use it.
Thanks again.

Try also:

{ cal 12 2011; cal 1 2012; } | awk '!NF {L=NR} !L {T[NR]=$0;next} {print T[NR-L], $0}' 
1 Like

The awk script relies on

!NF

and will not work on months which span 6 weeks, for example

cal 1 2011 cal 2 2012 etc...

won't work