2
I have a text file. Each line contains a string. Some strings are repeated. I want to remove repetition but I want to keep the first occurrence. For example:
line1
line1
line2
line3
line4
line3
line5
Should be
line1
line2
line3
line4
line5
I tried: sort file1 | uniq -u > file2
but this did not help. It removed all repeated strings while I want the first occurrence to be present. I do not need to sort. Just remove the exact repetition of a string in a new line while keeping everything else as it is.