How to remove duplicate lines ?

Salamouna

Elite Member
Jr. VIP
Joined
Aug 28, 2014
Messages
11,810
Reaction score
8,684
Hello i hope this will be the best section of the thread
i want to remove duplicate lines from notepad text those line can be text or numbers
i don't want just remove the duplicate lines but both .

Means :
1
2
1

results 2
so i get only the unique lines
 
Well you can copy it to excel, highlight duplicate lines and delete the highlighted ones
 
Code:
cd c:\where\your\file\is
type yourfile.txt | sort /unique > newfile.txt
In the command prompt
 
https://www.emeditor.com/
  • Then Ctrl-Shift-D
upload_2019-3-24_2-36-43.png
 
Notepad++ is your best bet when working with text files.
 
Hi majid, if you still looking for a solution, I could make custom python script for you.
 
I'm bored and yes, this is a backwards one liner but it was kind of a stream of consciousness

Code:
somehost:~$ cat a
This line will be removed
This line will remain
This line too
Because they are unique
However
This line will be removed
And this is different of a raw uniq because it removes both repeated lines


Code:
somehost:~$ cat a | sort | uniq -c | grep  -v -E  '^\s+[2-9]' | sed 's/^\s*[0-9]*\s*//'
And this is different of a raw uniq because it removes both repeated lines
Because they are unique
However
This line too
This line will remain
somehost:~$
 
Back
Top