join lines

input1

x  
x      

input2

y 
x
x
z
join input1 input2>>output

ouput

x  
x  

wanted output
ouput

x  x 
x  x  
   y
   z       
        

use paste command.

$ paste input1 input2
x       y
x       x
        x
        z

If you want the output sorted, use sort first and then give it as input to paste.

Hey you misunderstood the problem. in the wanted output x is matching with x see. paste just prints the two inputs side by side.

I think

join -j1 -v1 input1 input2

could do some thing. Now its working fine