Quick-and-dirty
How to remove duplicate lines in Bash when line order isn’t important
This works in a pinch, but as a side effect will sort the lines lexicographically. Avoiding a sort is possible but more complex…
Link to original
Remove all but the first occurrence of a line
How to remove all but the first occurrence of a line in Bash
Link to original
Remove all but the last occurrence of a line
How to remove all but the last occurrence of a line in Bash
Link to original