Delete duplicate lines when not sorted alphabetically
How do I delete lines that exist more than once, without sorting the lines alphabetically?
I use this in regex:
with this replace:
But I can see at least one duplicate still existing.
Also, if I were to sort it alphabetically, and use what’s written above, it returns lines like this as duplicates even though they aren’t.
Can someone help me with this problem?
Thanks in advance.
Hello, @t-c and All,
No, problem, as long as your file have been previously sorted ;-)
First add, preferably, an empty line after the last item of your list. Then, if you want :
To keep just one item of all the duplicated lines, use : SEARCH
To delete all duplicated lines of a file, use : SEARCH
I’m code-illiterate, I just use Notepad++ as an end-user so to speak, and I don’t really understand how to carry out the search you propose in your answer. Obviously it is not the regular Find command, because that would look for the string of characters literally in the text. Could you please add a small reply for dummies so that I can get rid of all my duplicates (and not just rid of one of each pair of duplicates).
Thank you so much in advance.
@guy038 just neglected to explicitly say (because the OP knew it already) that you need to set the Search mode to Regular expression before doing the other steps he outlined. Thus, check this button:
You could also try @Claudia-Frank 's excellent Pythonscript for sorting (it’s optional and I see you don’t want it) and removing duplicate lines; find it here and a discussion about it here. It’s user interface appears thus:
It works! This is awesome. Thank you both so much hahaha. I’m so happy. Thanks.
Oh, and I won’t be using that sorting script because that is so far above my capabilities I wouldn’t know where to start, but I usually sort and delete duplicates (just one duplicate line) with Textpad. Alternatively, I’ve learned today I can do it like this in Notepad++:
In the TextFX menu, click on TextFx Tools and then check the options
T: + Sort ascending
T: + Sort outputs only UNIQUE (at column) lines
and then executing the “sort” function (first or second topmost options)