And, the result:
join -t: a1 a b
But what I want is:
i.e. The colon in the last line is missing, any idea?
I would think you'd want the fields to be in a consistent position. If so then one of these would work using only one invocation of
join and no
$ join -t: -a1 -o 1.1,1.2,2.2 a b Tom:black:big Lily:pink: $ join -t: -a1 -o 1.1,2.2,1.2 a b Tom:big:black Lily::pink
This behavior is expected per
-a FILENUM print unpairable lines coming from file FILENUM, where FILENUM is 1 or 2, corresponding to FILE1 or FILE2
You can do it in two passes like this:
join -t: a b && join -t: -v1 a b|sed 's/:/::/'
or something along those lines.