How to append the output in a new column?

input1
john 20
bob 30
input2
john 60
bob 100
cat input1 >> output
cat input2 >> output

ouput

john 20
bob 30
john 60
bob 100

desired output

input1 input1 input2 input2
john 20 john 60
bob 30 bob 100

Try

join file[12]
john 20 60
bob 30 100

or

paste file[12]
john 20    john 60
bob 30    bob 100
1 Like

Hello quincyjones,

Could you please try following and let me know if this helps you.

awk 'FNR==NR{A[FNR]=$0;next} {printf("%s\n",FNR==1?A[FNR] FS A[FNR] FS $0 FS $0:A[FNR] FS $0)}'  Input_file1   Input_file2

Thanks,
R. Singh

Are you sure you want input1 input1 input2 input2 ? In the files there's only one record of each which it would be:

input1 input2
john 20 john 60
bob 30 bob 100

If this is the case paste is the strongest contender, but with space delimiter setup instead of a tab as RudiC's example.

paste -d' ' input{1,2}

Output:

input1 input2
john 20 john 60
bob 30 bob 100

I do not consider join an option, here, since lines must be sorted and there must be a common field in each line.