Retain the unmatched columns while joining

I have 2 files

file1
id  city    car type    model
1   york    subaru  impreza king
2   kampala toyota  corolla sissy
3   luzern  chrysler    gravity falcon
file2 
id  name    rating
3   zanzini PG
2   tara    X

when i use join sorted_file1 sorted_file2 >output i get something like this:

id  city    car type    model   name    rating
2   kampala toyota  corolla sissy   tara    X
3   luzern  chrysler    gravity falcon  zanzini PG

which is correct according to thecommand used. but i want to retain the unmatched line as well in output i,e.,'

ouput
id  city    car type    model   name    rating
1   york    subaru  impreza king
2   kampala toyota  corolla sissy   tara    X
3   luzern  chrysler    gravity falcon  zanzini PG

Try something like this:

#cat file1             
1   york    subaru  impreza king
2   kampala toyota  corolla sissy
3   luzern  chrysler    gravity falcon
#cat file2             
2   tara    X
3   zanzini PG
#join -a 1 file1 file2
1 york subaru impreza king
2 kampala toyota corolla sissy tara X
3 luzern chrysler gravity falcon zanzini PG
join -a 1 file1 file2

is printing output on the terminal properly but when i redirect the output

join -a 1 file1 file2 >output

it is not printing the entire columns.

---------- Post updated at 08:09 AM ---------- Previous update was at 06:26 AM ----------

sorted out the problem :slight_smile: