I know a bit of bash, but I am facing a problem to filter a file. I'll explain with an example :
Given a text file like the following (file1):
10.10.12 bib24 Avenger goodone
10.10.12 bib21 The_Dark_Knight_Rises betterone
10.10.12 bib53 Avenger goodone
10.10.12 bib35 Ice_Age wow
11.10.12 bib53 TheAmazingSpiderMan nice
11.10.12 bib54 TheAmazingSpiderMan nice
11.10.12 bib01 Avenger goodone
12.10.12 bib29 Avenger goodone
12.10.12 bib11 TheAmazingSpiderMan nice
12.10.12 bib03 Ice_Age wow
12.10.12 bib98 Ice_Age wow
14.10.12 bib12 Ice_Age wow
This is the result I want (file2):
10.10.12 bib24 Avenger goodone
10.10.12 bib21 The_Dark_Knight_Rises betterone
10.10.12 bib35 Ice_Age wow
11.10.12 bib53 TheAmazingSpiderMan nice
So my question is : which command do I use to get this result (file2) ? (i.e. first entry of a movie, and not taking into account columns/fields 1, 2, and 4).
I hope it's clear enough.
Here's one way using awk
:
awk '!a[$3]++' file.txt
Results:
10.10.12 bib24 Avenger goodone
10.10.12 bib21 The_Dark_Knight_Rises betterone
10.10.12 bib35 Ice_Age wow
11.10.12 bib53 TheAmazingSpiderMan nice
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With