I'm trying to concatenate two files, sort them by last name, delete duplicates and store them in a new file.
File's: "firstName lastName"
FileA + FileB --> FileC
I tried it with the sort command:
sort -uk2 fileA fileB > fileC
The problem is that this command deletes names with the same last name but diffrent first name.
"Hans Smith" + "Hans Smith" --> only one "Hans Smith" should remain. "Friedrich Bauer" + "Colin Bauer" --> should both be kept.
Any ideas?
First sort the whole lines and remove duplicates then sort by the second field:
sort -u fileA fileB | sort -k2 > fileC