Sunday, 15 September 2013

Sort column by occurrence in shell

Sort column by occurrence in shell

I'm new to unix. I'm trying to sort a file by the occurence of values in a
certain column in it:
IP - - Website
1.1.1 - - stackoverflow.com
0.0.5 - - a.com
1.1.1 - - google.com
expected result:
IP - - Website
1.1.1 - - stackoverflow.com
0.0.5 - - a.com
I tried different methods: - sort -k1 | uniq -c (didn't work because uniq
checks the whole line, including websites) - using sort -u -t- -k1
Can anyone help me, or at least tell me what I'm doing wrong please?

No comments:

Post a Comment