I compare two files with this command
comm -13 file1 file2
It works perfectly and says me differences. But I would like to show me also the line number (lines unique in second file).
file1:
a
d
e
f
g
file2:
a
b
c
d
e
I do:
comm -13 file1 file2
Output
b
c
But I need the line numbers where b and c are in file2, desired output:
2
3
Using awk:
Output:
Edit: As presented in the OP, the
commbehaves differently when filefile2has duplicates. Below solution should fix that (see comments and thanks @EdMorton):Output now (
file2has a duplicate entrydwhereFNR==5):Hopefully there aren't that many more pitfalls waiting...