Is there an easy way to print all lines of a file1
(so that the output has the same number of lines as the input file1
) but print a message such as NoMatch
where the first entries of file1 does not match the first entries of file2
?
file1:
Entry1 Entry2
a 2
b 3
c 4
d 5
file2:
a
b
b
a
d
d
Desired output:
Entry1
a 2
b 3
NoMatch 4
d 5
I am trying with
join -a1 -e "NoMatch" -11 -21 -o2.1 file1 file2
since I would like to keep the unpairable lines from file1
that do not match file2
, and give a message for these cases as "no", but this keeps all of my records also in file2
(which contains duplicated records), what am I doing wrong? Could this be because my second file is tab delimited and my first file is space delimited?
Thanks so much for all the help...