If I have a text file with the following conent
red apple
green apple
green apple
orange
orange
orange
Is there a Linux command or script that I can use to get the following result?
1 red apple
2 green apple
3 orange
If I have a text file with the following conent
red apple
green apple
green apple
orange
orange
orange
Is there a Linux command or script that I can use to get the following result?
1 red apple
2 green apple
3 orange
Can you live with an alphabetical, ordered list:
?
or
-u stands for unique, and uniqueness is only reached via sorting.
A solution which preserves the order:
and, with a file
The last two only remove duplicates, which follow immediately - which fits to your example.
Will print two apples, split by a banana.