I need to count the number of unique values based on two columns in a spreadsheet.
Suppose the file looks like this, ordered by name, surname, company:
joe allen ibm
joe smith ibm
joe allen google
joe smith google
rachel allen google
And I need to count the number of unique first names for each company while ignoring the surname:
joe ibm 2
joe google 2
rachel google 1
I have this code:
sort file.tsv | uniq -ci | awk '{print $2,$1}'
If I simply delete the surname column, that code will work. But if I don't want to delete that column, just have awk ignore it, and save the output to a new file?
The data is separated by tabs \t