Imagine I have this file in bash:
1 3 6 name1
1 2 7 name2
3 4 2 name1
2 2 2 name3
7 8 2 name2
1 2 9 name4
How could I extract just those lines which present the field "name" repeated and sort them?
My expected output would be:
1 3 6 name1
3 4 2 name1
1 2 7 name2
7 8 2 name2
I was trying to use sort -k4,4 myfile | uniq -D
, but I don't find how to tell uniq
to work with the 4th column.
Thanks!