Home » questions » Batch program to check a text file for duplicate entries?
Batch program to check a text file for duplicate entries?
I have a large text file with thousands of entries on it (each on a new line) which were copied and pasted from different sources, but the problem is that hundreds of the entries are likely to be there more than once. So I would like a batch program to look at this file (let's call it list.txt) and remove anything that appears twice (or more times) leaving only one of every entry. For example:
a
b
c
a
a
b
would become:
a
b
c
(Any duplicates have been removed, leaving only one of each unique entry in the list.)
Could answerers please leave the code in their answer, I will create a batch file from this. For a better chance of best answer, explanations of what different commands are doing should be included. Thanks.
Unfortunately, arnold's code does not work as a MS-DOS batch file (as he pointed out, it is unix), however the method of making a new list without duplicates is OK if that helps anyone out there who has decided to help me!
I am using Windows XP and unfortunately my skills as a programmer are... ahem.. not too brilliant as of yet!

Answers
land_bus
On 2006-08-03 09:28:24
take two
On 2006-08-06 10:08:49
CeeVee
On 2006-08-03 20:01:20
Mowgli
On 2006-08-05 23:59:12
rt11guru
On 2006-08-03 10:16:12
jaina986
On 2006-08-03 09:21:48
arnold
On 2006-08-03 09:16:07
Pands
On 2006-08-03 09:30:20