I want to sort input by number of appearances. However I don't want to delete either the unique or non-unique lines. For instance if I was given the following input:
Not unique
This line is unique
Not unique
Also not unique
Also unique
Also not unique
Not unique
I'd be looking for a set of pipelined commands that would output the following:
This line is unique
Also unique
Also not unique
Also not unique
Not unique
Not unique
Not unique
Thank you for any help that you can provide, I've been trying to use different combinations of unique and sort but can't figure it out, the solution would preferably be a one liner.
UPDATE: Thank you to all who responded, especially @batMan who's answer was exactly what I was looking for with commands with which I was familiar.
I'm still trying to learn how to pipeline and use multiple commands for seemingly simple tasks so is it possible for me to adapt his answer to work with 2 columns? For instance if the original input had been:
Notunique dog
Thislineisunique cat
Notunique parrot
Alsonotunique monkey
Alsounique zebra
Alsonotunique beaver
Notunique dragon
And I wanted the output to be sorted by first column like so:
Thislineisunique cat
Alsounique zebra
Alsonotunique monkey
Alsonotunique beaver
Notunique dog
Notunique parrot
Notunique dragon
Thank you all for being so helpful in advance!